Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -156,7 +156,7 @@ def convert_text_to_speech(input_text: str, source_language: str, target_languag
|
|
| 156 |
|
| 157 |
# Initialize variables
|
| 158 |
translated_text = ""
|
| 159 |
-
|
| 160 |
|
| 161 |
# Process each item in the result
|
| 162 |
for item in result:
|
|
@@ -167,23 +167,16 @@ def convert_text_to_speech(input_text: str, source_language: str, target_languag
|
|
| 167 |
# Assign the first non-URL string as the translated text
|
| 168 |
if not translated_text:
|
| 169 |
translated_text = item
|
| 170 |
-
elif
|
| 171 |
-
#
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
new_file_path = file_path
|
| 177 |
-
break
|
| 178 |
-
if new_file_path:
|
| 179 |
-
break
|
| 180 |
-
|
| 181 |
-
return new_file_path, translated_text
|
| 182 |
|
| 183 |
except Exception as e:
|
| 184 |
return f"Error in text-to-speech conversion: {str(e)}", ""
|
| 185 |
|
| 186 |
-
|
| 187 |
def process_image(image_input):
|
| 188 |
# Initialize the Gradio client with the URL of the Gradio server
|
| 189 |
client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
|
|
|
|
| 156 |
|
| 157 |
# Initialize variables
|
| 158 |
translated_text = ""
|
| 159 |
+
audio_file_path = ""
|
| 160 |
|
| 161 |
# Process each item in the result
|
| 162 |
for item in result:
|
|
|
|
| 167 |
# Assign the first non-URL string as the translated text
|
| 168 |
if not translated_text:
|
| 169 |
translated_text = item
|
| 170 |
+
elif isinstance(item, tuple) and len(item) == 2:
|
| 171 |
+
# Assuming the item is a tuple containing sample rate and audio data
|
| 172 |
+
audio_file_path = save_audio(item) # Save the audio file
|
| 173 |
+
break
|
| 174 |
+
|
| 175 |
+
return audio_file_path, translated_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
except Exception as e:
|
| 178 |
return f"Error in text-to-speech conversion: {str(e)}", ""
|
| 179 |
|
|
|
|
| 180 |
def process_image(image_input):
|
| 181 |
# Initialize the Gradio client with the URL of the Gradio server
|
| 182 |
client = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
|