Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,16 +33,16 @@ def transcribe(audio, state=""):
|
|
| 33 |
if state is None:
|
| 34 |
state = ""
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
with tempfile.TemporaryDirectory() as tmpdir:
|
| 39 |
# Filepath transcribe
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
# Direct transcribe
|
| 45 |
-
transcriptions = model.transcribe([audio])
|
| 46 |
|
| 47 |
# if transcriptions form a tuple (from RNNT), extract just "best" hypothesis
|
| 48 |
if type(transcriptions) == tuple and len(transcriptions) == 2:
|
|
|
|
| 33 |
if state is None:
|
| 34 |
state = ""
|
| 35 |
|
| 36 |
+
audio_data = process_audio_file(audio)
|
| 37 |
|
| 38 |
with tempfile.TemporaryDirectory() as tmpdir:
|
| 39 |
# Filepath transcribe
|
| 40 |
+
audio_path = os.path.join(tmpdir, f'audio_{uuid.uuid4()}.wav')
|
| 41 |
+
soundfile.write(audio_path, audio_data, SAMPLE_RATE)
|
| 42 |
+
transcriptions = model.transcribe([audio_path])
|
| 43 |
|
| 44 |
# Direct transcribe
|
| 45 |
+
# transcriptions = model.transcribe([audio])
|
| 46 |
|
| 47 |
# if transcriptions form a tuple (from RNNT), extract just "best" hypothesis
|
| 48 |
if type(transcriptions) == tuple and len(transcriptions) == 2:
|