Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,20 +26,23 @@ def process_audio_file(file):
|
|
26 |
return data
|
27 |
|
28 |
|
29 |
-
def transcribe(
|
30 |
# Grant additional context
|
31 |
-
time.sleep(
|
32 |
|
33 |
if state is None:
|
34 |
state = ""
|
35 |
|
36 |
-
audio_data = process_audio_file(
|
37 |
|
38 |
with tempfile.TemporaryDirectory() as tmpdir:
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
transcriptions = model.transcribe([audio_path])
|
|
|
|
|
|
|
43 |
|
44 |
# if transcriptions form a tuple (from RNNT), extract just "best" hypothesis
|
45 |
if type(transcriptions) == tuple and len(transcriptions) == 2:
|
|
|
26 |
return data
|
27 |
|
28 |
|
29 |
+
def transcribe(audio, state=""):
|
30 |
# Grant additional context
|
31 |
+
time.sleep(2)
|
32 |
|
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:
|