Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import requests
|
|
| 2 |
from pydub import AudioSegment
|
| 3 |
from io import BytesIO
|
| 4 |
import gradio as gr
|
| 5 |
-
import
|
| 6 |
|
| 7 |
# Hugging Face API URLs
|
| 8 |
API_URL_ROBERTA = "https://api-inference.huggingface.co/models/deepset/roberta-base-squad2"
|
|
@@ -39,9 +39,9 @@ def generate_speech(api_token, answer):
|
|
| 39 |
response.raise_for_status() # Raise an error for bad responses
|
| 40 |
audio = response.content
|
| 41 |
audio_segment = AudioSegment.from_file(BytesIO(audio), format="wav")
|
| 42 |
-
|
| 43 |
-
audio_segment.export(
|
| 44 |
-
return
|
| 45 |
except requests.exceptions.HTTPError as e:
|
| 46 |
print(f"HTTP error occurred: {e}")
|
| 47 |
return None
|
|
|
|
| 2 |
from pydub import AudioSegment
|
| 3 |
from io import BytesIO
|
| 4 |
import gradio as gr
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
# Hugging Face API URLs
|
| 8 |
API_URL_ROBERTA = "https://api-inference.huggingface.co/models/deepset/roberta-base-squad2"
|
|
|
|
| 39 |
response.raise_for_status() # Raise an error for bad responses
|
| 40 |
audio = response.content
|
| 41 |
audio_segment = AudioSegment.from_file(BytesIO(audio), format="wav")
|
| 42 |
+
audio_file_path = "/tmp/answer.wav"
|
| 43 |
+
audio_segment.export(audio_file_path, format="wav")
|
| 44 |
+
return audio_file_path
|
| 45 |
except requests.exceptions.HTTPError as e:
|
| 46 |
print(f"HTTP error occurred: {e}")
|
| 47 |
return None
|