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

took out last trascribed time stuff

Browse files
Files changed (1) hide show
  1. infer.py +3 -12
infer.py CHANGED
@@ -126,15 +126,9 @@ async def read_root():
126
  import tempfile
127
 
128
 
129
- def transcribe_core_ws(audio_file, last_transcribed_time):
130
- """
131
- Transcribe the audio file and return only the segments that have not been processed yet.
132
-
133
- """
134
- logging.info(f"Starting transcription for file: {audio_file} from {last_transcribed_time} seconds.")
135
 
136
  ret = {'segments': []}
137
- new_last_transcribed_time = last_transcribed_time
138
 
139
  try:
140
  # Transcribe the entire audio file
@@ -236,7 +230,7 @@ async def websocket_transcribe(websocket: WebSocket):
236
  try:
237
  # Receive the next chunk of PCM audio data
238
  logging.info("in try before recive ")
239
- audio_chunk = await websocket.receive_bytes()
240
  logging.info(f"type of audio chunk : {type(audio_chunk)}")
241
 
242
  logging.info("after recieve")
@@ -293,10 +287,7 @@ async def websocket_transcribe(websocket: WebSocket):
293
  else:
294
  logging.error(f"Temporary WAV file {temp_wav_file.name} does not exist.")
295
  raise Exception(f"Temporary WAV file {temp_wav_file.name} not found.")
296
-
297
- # Call the transcription function with the WAV file path
298
- partial_result = transcribe_core_ws(temp_wav_file.name,
299
- last_transcribed_time)
300
  segments.extend(partial_result['segments'])
301
 
302
  # Clear the buffer after transcription
 
126
  import tempfile
127
 
128
 
129
+ def transcribe_core_ws(audio_file):
 
 
 
 
 
130
 
131
  ret = {'segments': []}
 
132
 
133
  try:
134
  # Transcribe the entire audio file
 
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
+ partial_result = transcribe_core_ws(temp_wav_file)
 
 
 
291
  segments.extend(partial_result['segments'])
292
 
293
  # Clear the buffer after transcription