Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -199,41 +199,37 @@ def convert_text_to_speech(input_text: str, source_language: str, target_languag
|
|
199 |
client = Client("https://facebook-seamless-m4t.hf.space/--replicas/8cllp/")
|
200 |
|
201 |
try:
|
|
|
202 |
result = client.predict(
|
203 |
-
"T2ST",
|
204 |
-
"text",
|
205 |
-
None,
|
206 |
-
None,
|
207 |
-
input_text,
|
208 |
-
source_language,
|
209 |
-
target_language,
|
210 |
-
api_name="/run"
|
211 |
)
|
212 |
-
|
213 |
# Initialize variables
|
214 |
translated_text = ""
|
215 |
audio_file_path = ""
|
216 |
|
217 |
-
# Process
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
#
|
224 |
-
|
225 |
-
|
226 |
-
elif isinstance(item, tuple) and len(item) == 2:
|
227 |
-
# Assuming the item is a tuple containing sample rate and audio data
|
228 |
-
audio_file_path = save_audio(item) # Save the audio file
|
229 |
-
break
|
230 |
|
231 |
return audio_file_path, translated_text
|
232 |
|
233 |
except Exception as e:
|
234 |
return None, f"Error in text-to-speech conversion: {str(e)}"
|
235 |
|
236 |
-
|
237 |
def process_image(image_input):
|
238 |
# Initialize the Gradio client with the URL of the Gradio server
|
239 |
client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
|
|
|
199 |
client = Client("https://facebook-seamless-m4t.hf.space/--replicas/8cllp/")
|
200 |
|
201 |
try:
|
202 |
+
# Make a prediction request to the client
|
203 |
result = client.predict(
|
204 |
+
task_name="T2ST",
|
205 |
+
audio_source="text", # Since we are doing text-to-speech
|
206 |
+
input_audio_mic=None,
|
207 |
+
input_audio_file=None,
|
208 |
+
input_text=input_text,
|
209 |
+
source_language=source_language,
|
210 |
+
target_language=target_language,
|
211 |
+
api_name="/run"
|
212 |
)
|
213 |
+
|
214 |
# Initialize variables
|
215 |
translated_text = ""
|
216 |
audio_file_path = ""
|
217 |
|
218 |
+
# Process the result
|
219 |
+
if result:
|
220 |
+
# Assuming the result is a tuple containing audio data and translated text
|
221 |
+
audio_data, translated_text = result
|
222 |
+
|
223 |
+
if audio_data:
|
224 |
+
# Assuming audio_data is a tuple containing sample rate and audio numpy array
|
225 |
+
sample_rate, audio_numpy_array = audio_data
|
226 |
+
audio_file_path = save_audio(sample_rate, audio_numpy_array) # Save the audio file
|
|
|
|
|
|
|
|
|
227 |
|
228 |
return audio_file_path, translated_text
|
229 |
|
230 |
except Exception as e:
|
231 |
return None, f"Error in text-to-speech conversion: {str(e)}"
|
232 |
|
|
|
233 |
def process_image(image_input):
|
234 |
# Initialize the Gradio client with the URL of the Gradio server
|
235 |
client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
|