AshDavid12 commited on
Commit
5b3e211
·
1 Parent(s): b50221f

reading the temp wav file and then sending to trasncribe core

Browse files
Files changed (1) hide show
  1. infer.py +5 -2
infer.py CHANGED
@@ -230,7 +230,7 @@ async def websocket_transcribe(websocket: WebSocket):
230
  try:
231
  # Receive the next chunk of PCM audio data
232
  logging.info("in try before recive ")
233
- audio_chunk = await asyncio.wait_for(websocket.receive_bytes(),timeout=10.0)
234
  logging.info(f"type of audio chunk : {type(audio_chunk)}")
235
 
236
  logging.info("after recieve")
@@ -287,7 +287,10 @@ async def websocket_transcribe(websocket: WebSocket):
287
  else:
288
  logging.error(f"Temporary WAV file {temp_wav_file.name} does not exist.")
289
  raise Exception(f"Temporary WAV file {temp_wav_file.name} not found.")
290
- partial_result = transcribe_core_ws(temp_wav_file)
 
 
 
291
  segments.extend(partial_result['segments'])
292
 
293
  # Clear the buffer after transcription
 
230
  try:
231
  # Receive the next chunk of PCM audio data
232
  logging.info("in try before recive ")
233
+ audio_chunk = await asyncio.wait_for(websocket.receive_bytes(), timeout=10.0)
234
  logging.info(f"type of audio chunk : {type(audio_chunk)}")
235
 
236
  logging.info("after recieve")
 
287
  else:
288
  logging.error(f"Temporary WAV file {temp_wav_file.name} does not exist.")
289
  raise Exception(f"Temporary WAV file {temp_wav_file.name} not found.")
290
+
291
+ with open(temp_wav_file.name, 'rb') as audio_file:
292
+ audio_data = audio_file.read()
293
+ partial_result = transcribe_core_ws(audio_data)
294
  segments.extend(partial_result['segments'])
295
 
296
  # Clear the buffer after transcription