Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,8 +4,16 @@ import gradio as gr
|
|
4 |
model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
|
5 |
|
6 |
def transcribe(audio):
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
demo = gr.Interface(
|
11 |
fn=transcribe,
|
|
|
4 |
model = EncoderASR.from_hparams("speechbrain/asr-wav2vec2-dvoice-wolof")
|
5 |
|
6 |
def transcribe(audio):
|
7 |
+
if isinstance(audio, str): # Si audio est un chemin de fichier
|
8 |
+
return model.transcribe_file(audio)
|
9 |
+
else: # Si audio est un tuple (cas du microphone)
|
10 |
+
sr, y = audio
|
11 |
+
y = y.astype(np.float32)
|
12 |
+
y /= np.max(np.abs(y))
|
13 |
+
# Enregistrer temporairement l'audio pour utiliser la méthode transcribe_file
|
14 |
+
temp_file = 'temp.wav'
|
15 |
+
sf.write(temp_file, y, sr)
|
16 |
+
return model.transcribe_file(temp_file)
|
17 |
|
18 |
demo = gr.Interface(
|
19 |
fn=transcribe,
|