Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,10 @@ import nltk
|
|
3 |
from nltk.tokenize import word_tokenize
|
4 |
from nltk.corpus import stopwords
|
5 |
from nltk.stem import WordNetLemmatizer
|
6 |
-
from deep_translator import GoogleTranslator
|
7 |
from gtts import gTTS
|
8 |
import tempfile
|
9 |
import os
|
|
|
10 |
|
11 |
# Download necessary NLTK data
|
12 |
nltk.download('punkt', quiet=True)
|
@@ -32,7 +32,6 @@ def text_to_speech(text):
|
|
32 |
|
33 |
def process_input(input_text, input_audio, feature, target_language, output_language):
|
34 |
if input_audio is not None:
|
35 |
-
# For now, we'll just return a message as we can't process audio input
|
36 |
return "Audio input processing is not available in this version.", None
|
37 |
|
38 |
if not input_text:
|
@@ -43,7 +42,7 @@ def process_input(input_text, input_audio, feature, target_language, output_lang
|
|
43 |
if feature == "Translation":
|
44 |
result = translate_text(processed_text, target_language)
|
45 |
elif feature == "Voice Command":
|
46 |
-
result = "Voice command feature
|
47 |
elif feature == "Transcription":
|
48 |
result = processed_text
|
49 |
else:
|
@@ -66,12 +65,12 @@ with gr.Blocks() as demo:
|
|
66 |
|
67 |
with gr.Row():
|
68 |
input_text = gr.Textbox(label="Input Text")
|
69 |
-
input_audio = gr.Audio(label="Input Audio", type="filepath", visible=False)
|
70 |
|
71 |
with gr.Row():
|
72 |
feature = gr.Radio(["Translation", "Voice Command", "Transcription"], label="Feature")
|
73 |
-
target_language = gr.Textbox(label="Target Language
|
74 |
-
output_language = gr.Textbox(label="Output Language
|
75 |
|
76 |
submit_button = gr.Button("Process")
|
77 |
result_text = gr.Textbox(label="Result")
|
|
|
3 |
from nltk.tokenize import word_tokenize
|
4 |
from nltk.corpus import stopwords
|
5 |
from nltk.stem import WordNetLemmatizer
|
|
|
6 |
from gtts import gTTS
|
7 |
import tempfile
|
8 |
import os
|
9 |
+
from deep_translator import GoogleTranslator
|
10 |
|
11 |
# Download necessary NLTK data
|
12 |
nltk.download('punkt', quiet=True)
|
|
|
32 |
|
33 |
def process_input(input_text, input_audio, feature, target_language, output_language):
|
34 |
if input_audio is not None:
|
|
|
35 |
return "Audio input processing is not available in this version.", None
|
36 |
|
37 |
if not input_text:
|
|
|
42 |
if feature == "Translation":
|
43 |
result = translate_text(processed_text, target_language)
|
44 |
elif feature == "Voice Command":
|
45 |
+
result = "Voice command feature not implemented in this example"
|
46 |
elif feature == "Transcription":
|
47 |
result = processed_text
|
48 |
else:
|
|
|
65 |
|
66 |
with gr.Row():
|
67 |
input_text = gr.Textbox(label="Input Text")
|
68 |
+
input_audio = gr.Audio(label="Input Audio", type="filepath", visible=False)
|
69 |
|
70 |
with gr.Row():
|
71 |
feature = gr.Radio(["Translation", "Voice Command", "Transcription"], label="Feature")
|
72 |
+
target_language = gr.Textbox(label="Target Language ")
|
73 |
+
output_language = gr.Textbox(label="Output Language ")
|
74 |
|
75 |
submit_button = gr.Button("Process")
|
76 |
result_text = gr.Textbox(label="Result")
|