EC2 Default User commited on
Commit
32e8a57
1 Parent(s): 92aeb17
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -45,6 +45,7 @@ def run_shell_cmd(command):
45
  def wav_to_pcm(input_file, output_file):
46
  cmd = "ffmpeg -i " + input_file + " -f s16le -ar 16000 -ac 1 -acodec pcm_s16le " + output_file
47
  run_shell_cmd(cmd)
 
48
 
49
  openai.api_key = os.environ["OPENAI_API_KEY"]
50
 
@@ -189,13 +190,17 @@ def predict(input, history=[]):
189
  def transcribe_func_new(audio):
190
  audio_file = open(audio, "rb")
191
  wav_file = audio_file.name
192
- print("audio_file: "+wav_file)
193
  #transcript = openai.Audio.transcribe("whisper-1", audio_file)
194
  #return transcript['text']
195
 
196
  pcm_file = os.path.splitext(wav_file)[0] + ".pcm"
197
 
198
  wav_to_pcm(wav_file, pcm_file)
 
 
 
 
199
  AUDIO_PATH=pcm_file
200
 
201
  loop = asyncio.get_event_loop()
 
45
  def wav_to_pcm(input_file, output_file):
46
  cmd = "ffmpeg -i " + input_file + " -f s16le -ar 16000 -ac 1 -acodec pcm_s16le " + output_file
47
  run_shell_cmd(cmd)
48
+
49
 
50
  openai.api_key = os.environ["OPENAI_API_KEY"]
51
 
 
190
  def transcribe_func_new(audio):
191
  audio_file = open(audio, "rb")
192
  wav_file = audio_file.name
193
+ print("wav_file: "+wav_file)
194
  #transcript = openai.Audio.transcribe("whisper-1", audio_file)
195
  #return transcript['text']
196
 
197
  pcm_file = os.path.splitext(wav_file)[0] + ".pcm"
198
 
199
  wav_to_pcm(wav_file, pcm_file)
200
+ if os.path.exists(file_path):
201
+ print("pcm file exists")
202
+ else:
203
+ print("pcm file does not exist")
204
  AUDIO_PATH=pcm_file
205
 
206
  loop = asyncio.get_event_loop()