Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
# Load the pipeline for speech recognition and translation
|
5 |
pipe = pipeline(
|
@@ -12,11 +13,8 @@ tts = pipeline("text-to-speech", model="Baghdad99/english_voice_tts")
|
|
12 |
|
13 |
# Define the function to translate speech
|
14 |
def translate_speech(audio):
|
15 |
-
# Extract the audio data from the tuple
|
16 |
-
audio_data = audio[0]
|
17 |
-
|
18 |
# Use the speech recognition pipeline to transcribe the audio
|
19 |
-
transcription = pipe(
|
20 |
|
21 |
# Use the translation pipeline to translate the transcription
|
22 |
translated_text = translator(transcription, return_tensors="pt", padding=True)
|
@@ -40,5 +38,4 @@ iface = gr.Interface(
|
|
40 |
description="Realtime demo for Hausa to English translation using speech recognition and text-to-speech synthesis."
|
41 |
)
|
42 |
|
43 |
-
|
44 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
import numpy as np
|
4 |
|
5 |
# Load the pipeline for speech recognition and translation
|
6 |
pipe = pipeline(
|
|
|
13 |
|
14 |
# Define the function to translate speech
|
15 |
def translate_speech(audio):
|
|
|
|
|
|
|
16 |
# Use the speech recognition pipeline to transcribe the audio
|
17 |
+
transcription = pipe(audio)["transcription"]
|
18 |
|
19 |
# Use the translation pipeline to translate the transcription
|
20 |
translated_text = translator(transcription, return_tensors="pt", padding=True)
|
|
|
38 |
description="Realtime demo for Hausa to English translation using speech recognition and text-to-speech synthesis."
|
39 |
)
|
40 |
|
|
|
41 |
iface.launch()
|