smajumdar commited on
Commit
e954933
·
1 Parent(s): d65b067

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -26,20 +26,23 @@ def process_audio_file(file):
26
  return data
27
 
28
 
29
- def transcribe(Audio, state=""):
30
  # Grant additional context
31
- time.sleep(1)
32
 
33
  if state is None:
34
  state = ""
35
 
36
- audio_data = process_audio_file(Audio)
37
 
38
  with tempfile.TemporaryDirectory() as tmpdir:
39
- audio_path = os.path.join(tmpdir, f'audio_{uuid.uuid4()}.wav')
40
- soundfile.write(audio_path, audio_data, SAMPLE_RATE)
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: