Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -177,14 +177,13 @@ def process_image(image_file_path):
|
|
| 177 |
except Exception as e:
|
| 178 |
return f"Error occurred during image processing: {e}"
|
| 179 |
|
| 180 |
-
def process_speech(audio_input, source_language, target_language="English"):
|
| 181 |
|
|
|
|
| 182 |
if audio_input is None:
|
| 183 |
return "No audio input provided."
|
| 184 |
try:
|
| 185 |
-
# Predict using the client
|
| 186 |
result = seamless_client.predict(
|
| 187 |
-
audio_input,
|
| 188 |
source_language,
|
| 189 |
target_language,
|
| 190 |
api_name="/s2tt"
|
|
@@ -194,7 +193,6 @@ def process_speech(audio_input, source_language, target_language="English"):
|
|
| 194 |
return f"Error in speech processing: {str(e)}"
|
| 195 |
|
| 196 |
def convert_text_to_speech(input_text, source_language, target_language):
|
| 197 |
-
|
| 198 |
try:
|
| 199 |
result = seamless_client.predict(
|
| 200 |
input_text,
|
|
@@ -209,7 +207,6 @@ def convert_text_to_speech(input_text, source_language, target_language):
|
|
| 209 |
except Exception as e:
|
| 210 |
return None, f"Error in text-to-speech conversion: {str(e)}"
|
| 211 |
|
| 212 |
-
|
| 213 |
def query_vectara(text):
|
| 214 |
user_message = text
|
| 215 |
customer_id = os.getenv('CUSTOMER_ID')
|
|
@@ -370,7 +367,7 @@ def process_and_query(input_language=None, audio_input=None, image_input=None, t
|
|
| 370 |
# Process audio input
|
| 371 |
elif audio_input is not None:
|
| 372 |
audio_file_path = save_audio(audio_input)
|
| 373 |
-
audio_text = process_speech(input_language,
|
| 374 |
combined_text += "\n\n**Audio Input:**\n" + audio_text
|
| 375 |
|
| 376 |
# Process text input
|
|
|
|
| 177 |
except Exception as e:
|
| 178 |
return f"Error occurred during image processing: {e}"
|
| 179 |
|
|
|
|
| 180 |
|
| 181 |
+
def process_speech(audio_input, source_language, target_language="English"):
|
| 182 |
if audio_input is None:
|
| 183 |
return "No audio input provided."
|
| 184 |
try:
|
|
|
|
| 185 |
result = seamless_client.predict(
|
| 186 |
+
audio_input,
|
| 187 |
source_language,
|
| 188 |
target_language,
|
| 189 |
api_name="/s2tt"
|
|
|
|
| 193 |
return f"Error in speech processing: {str(e)}"
|
| 194 |
|
| 195 |
def convert_text_to_speech(input_text, source_language, target_language):
|
|
|
|
| 196 |
try:
|
| 197 |
result = seamless_client.predict(
|
| 198 |
input_text,
|
|
|
|
| 207 |
except Exception as e:
|
| 208 |
return None, f"Error in text-to-speech conversion: {str(e)}"
|
| 209 |
|
|
|
|
| 210 |
def query_vectara(text):
|
| 211 |
user_message = text
|
| 212 |
customer_id = os.getenv('CUSTOMER_ID')
|
|
|
|
| 367 |
# Process audio input
|
| 368 |
elif audio_input is not None:
|
| 369 |
audio_file_path = save_audio(audio_input)
|
| 370 |
+
audio_text = process_speech(audio_file_path, input_language, "English")
|
| 371 |
combined_text += "\n\n**Audio Input:**\n" + audio_text
|
| 372 |
|
| 373 |
# Process text input
|