RASMUS commited on
Commit
9f5577b
1 Parent(s): 3380259

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -31,7 +31,8 @@ def speech_to_text(audio_path, whisper_model):
31
  _,file_ending = os.path.splitext(f'{audio_path}')
32
  print(f'file enging is {file_ending}')
33
  print("starting conversion to wav")
34
- os.system(f'ffmpeg -i "{audio_path}" -ar 16000 -y -ac 1 -c:a pcm_s16le "{audio_path.replace(file_ending, ".wav")}"')
 
35
  print("conversion to wav ready")
36
 
37
  except Exception as e:
@@ -40,9 +41,9 @@ def speech_to_text(audio_path, whisper_model):
40
  try:
41
 
42
  print("starting whisper c++")
43
- srt_path = str(audio_path.replace(file_ending, ".wav")) + ".srt"
44
  os.system(f'rm -f {srt_path}')
45
- os.system(f'./whisper.cpp/main "{audio_path.replace(file_ending, ".wav")}" -t 4 -m ./{whisper_modelpath_translator.get(whisper_model)} -osrt')
46
  print("starting whisper done with whisper")
47
  except Exception as e:
48
  raise RuntimeError(f'Error running Whisper cpp model: {e}') from e
 
31
  _,file_ending = os.path.splitext(f'{audio_path}')
32
  print(f'file enging is {file_ending}')
33
  print("starting conversion to wav")
34
+ new_path = audio_path.replace(file_ending, "_converted.wav")
35
+ os.system(f'ffmpeg -i "{audio_path}" -ar 16000 -y -ac 1 -c:a pcm_s16le "{new_path}"')
36
  print("conversion to wav ready")
37
 
38
  except Exception as e:
 
41
  try:
42
 
43
  print("starting whisper c++")
44
+ srt_path = new_path + ".srt"
45
  os.system(f'rm -f {srt_path}')
46
+ os.system(f'./whisper.cpp/main "{new_path}" -t 4 -m ./{whisper_modelpath_translator.get(whisper_model)} -osrt')
47
  print("starting whisper done with whisper")
48
  except Exception as e:
49
  raise RuntimeError(f'Error running Whisper cpp model: {e}') from e