Spaces:
Runtime error
Runtime error
tonic
commited on
Commit
·
57faa55
1
Parent(s):
1047e1e
bug fixes for file
Browse files- app.py +9 -8
- audio_files/audio_3505178120260920029.wav +0 -0
- script.py +10 -0
app.py
CHANGED
@@ -165,10 +165,11 @@ def process_text_to_audio(text, translatefrom="English", translateto="English",
|
|
165 |
translateto,
|
166 |
api_name="/t2st"
|
167 |
)
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
|
|
172 |
|
173 |
def save_audio_data_to_file(audio_data, directory="audio_files", filename="output_audio.wav"):
|
174 |
"""
|
@@ -330,13 +331,13 @@ def update_outputs(inputlanguage, target_language, audio, image, text, file):
|
|
330 |
image=image, file=file, audio=audio, text=text,
|
331 |
translateto=target_language, translatefrom=inputlanguage
|
332 |
)
|
|
|
|
|
333 |
output_tuple = (processed_text, audio_output)
|
334 |
for i in range(len(top_phrases)):
|
335 |
-
output_tuple += (top_phrases[i], translations[i]
|
336 |
-
|
337 |
while len(output_tuple) < 14:
|
338 |
-
output_tuple += ("", "",
|
339 |
-
|
340 |
return output_tuple
|
341 |
|
342 |
def interface_func(inputlanguage, target_language, audio, image, text, file):
|
|
|
165 |
translateto,
|
166 |
api_name="/t2st"
|
167 |
)
|
168 |
+
text_hash = hashlib.md5(text.encode('utf-8')).hexdigest()
|
169 |
+
filename = f"{filename_prefix}_{text_hash}.wav"
|
170 |
+
audio_file_path = save_audio_data_to_file(audio_response[0], filename=filename)
|
171 |
+
|
172 |
+
return audio_response[0], audio_file_path
|
173 |
|
174 |
def save_audio_data_to_file(audio_data, directory="audio_files", filename="output_audio.wav"):
|
175 |
"""
|
|
|
331 |
image=image, file=file, audio=audio, text=text,
|
332 |
translateto=target_language, translatefrom=inputlanguage
|
333 |
)
|
334 |
+
audio_output = gr.Audio(file_path=audio_output_path)
|
335 |
+
audio_outputs_components = [(gr.Audio(file_path=ao[0]), gr.Audio(file_path=ao[1])) for ao in audio_outputs]
|
336 |
output_tuple = (processed_text, audio_output)
|
337 |
for i in range(len(top_phrases)):
|
338 |
+
output_tuple += (top_phrases[i], translations[i]) + audio_outputs_components[i]
|
|
|
339 |
while len(output_tuple) < 14:
|
340 |
+
output_tuple += ("", "", gr.Audio(), gr.Audio())
|
|
|
341 |
return output_tuple
|
342 |
|
343 |
def interface_func(inputlanguage, target_language, audio, image, text, file):
|
audio_files/audio_3505178120260920029.wav
ADDED
File without changes
|
script.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from gradio_client import Client
|
2 |
+
|
3 |
+
client = Client("https://facebook-seamless-m4t-v2-large.hf.space/--replicas/v4gsf/")
|
4 |
+
result = client.predict(
|
5 |
+
"Hello my name is tonic!", # str in 'Input text' Textbox component
|
6 |
+
"English", # Literal[Afrikaans, Amharic, Armenian, Assamese, Basque, Belarusian, Bengali, Bosnian, Bulgarian, Burmese, Cantonese, Catalan, Cebuano, Central Kurdish, Croatian, Czech, Danish, Dutch, Egyptian Arabic, English, Estonian, Finnish, French, Galician, Ganda, Georgian, German, Greek, Gujarati, Halh Mongolian, Hebrew, Hindi, Hungarian, Icelandic, Igbo, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Kazakh, Khmer, Korean, Kyrgyz, Lao, Lithuanian, Luo, Macedonian, Maithili, Malayalam, Maltese, Mandarin Chinese, Marathi, Meitei, Modern Standard Arabic, Moroccan Arabic, Nepali, North Azerbaijani, Northern Uzbek, Norwegian Bokmål, Norwegian Nynorsk, Nyanja, Odia, Polish, Portuguese, Punjabi, Romanian, Russian, Serbian, Shona, Sindhi, Slovak, Slovenian, Somali, Southern Pashto, Spanish, Standard Latvian, Standard Malay, Swahili, Swedish, Tagalog, Tajik, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Vietnamese, Welsh, West Central Oromo, Western Persian, Yoruba, Zulu] in 'Source language' Dropdown component
|
7 |
+
"French", # Literal[Bengali, Catalan, Czech, Danish, Dutch, English, Estonian, Finnish, French, German, Hindi, Indonesian, Italian, Japanese, Korean, Maltese, Mandarin Chinese, Modern Standard Arabic, Northern Uzbek, Polish, Portuguese, Romanian, Russian, Slovak, Spanish, Swahili, Swedish, Tagalog, Telugu, Thai, Turkish, Ukrainian, Urdu, Vietnamese, Welsh, Western Persian] in 'Target language' Dropdown component
|
8 |
+
api_name="/t2st"
|
9 |
+
)
|
10 |
+
print(result)
|