Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import requests
|
|
3 |
import numpy as np
|
4 |
from pydub import AudioSegment
|
5 |
import io
|
|
|
6 |
|
7 |
# Define the Hugging Face Inference API URLs and headers
|
8 |
ASR_API_URL = "https://api-inference.huggingface.co/models/Baghdad99/saad-speech-recognition-hausa-audio-to-text"
|
@@ -35,15 +36,8 @@ def translate_speech(audio_file):
|
|
35 |
response = requests.post(TTS_API_URL, headers=headers, json={"inputs": translated_text})
|
36 |
audio_bytes = response.content
|
37 |
|
38 |
-
#
|
39 |
-
|
40 |
-
|
41 |
-
# Convert the audio segment to a numpy array
|
42 |
-
audio_data = np.array(audio_segment.get_array_of_samples())
|
43 |
-
if audio_segment.channels == 2:
|
44 |
-
audio_data = audio_data.reshape((-1, 2))
|
45 |
-
|
46 |
-
return audio_data
|
47 |
|
48 |
# Define the Gradio interface
|
49 |
iface = gr.Interface(
|
|
|
3 |
import numpy as np
|
4 |
from pydub import AudioSegment
|
5 |
import io
|
6 |
+
from IPython.display import Audio
|
7 |
|
8 |
# Define the Hugging Face Inference API URLs and headers
|
9 |
ASR_API_URL = "https://api-inference.huggingface.co/models/Baghdad99/saad-speech-recognition-hausa-audio-to-text"
|
|
|
36 |
response = requests.post(TTS_API_URL, headers=headers, json={"inputs": translated_text})
|
37 |
audio_bytes = response.content
|
38 |
|
39 |
+
# Display the audio output
|
40 |
+
return Audio(audio_bytes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
# Define the Gradio interface
|
43 |
iface = gr.Interface(
|