AshDavid12 commited on
Commit
5ac76de
·
1 Parent(s): 8521d41
Files changed (2) hide show
  1. client.py +7 -7
  2. infer.py +1 -1
client.py CHANGED
@@ -43,12 +43,12 @@ async def send_audio(websocket):
43
  for chunk in response.iter_content(chunk_size=1024): # Stream in chunks
44
  if chunk:
45
  audio_buffer.extend(chunk)
46
- print(f"Received audio chunk of size {len(chunk)} bytes.")
47
 
48
  # Send buffered audio data once it's large enough
49
  if len(audio_buffer) >= buffer_size:
50
  await websocket.send(audio_buffer)
51
- print(f"Sent {len(audio_buffer)} bytes of audio data.")
52
  audio_buffer.clear()
53
  await asyncio.sleep(0.01)
54
 
@@ -60,11 +60,11 @@ async def receive_transcription(websocket):
60
  while True:
61
  try:
62
  transcription = await websocket.recv() # Receive transcription from the server
63
- new_segments = process_transcription_results(transcription)
64
- # Now handle only new segments
65
- if new_segments:
66
- for segment in new_segments:
67
- print(f"New Segment: {segment['text']}")
68
  print(f"Transcription: {transcription}")
69
  except Exception as e:
70
  print(f"Error receiving transcription: {e}")
 
43
  for chunk in response.iter_content(chunk_size=1024): # Stream in chunks
44
  if chunk:
45
  audio_buffer.extend(chunk)
46
+ #print(f"Received audio chunk of size {len(chunk)} bytes.")
47
 
48
  # Send buffered audio data once it's large enough
49
  if len(audio_buffer) >= buffer_size:
50
  await websocket.send(audio_buffer)
51
+ #print(f"Sent {len(audio_buffer)} bytes of audio data.")
52
  audio_buffer.clear()
53
  await asyncio.sleep(0.01)
54
 
 
60
  while True:
61
  try:
62
  transcription = await websocket.recv() # Receive transcription from the server
63
+ # new_segments = process_transcription_results(transcription)
64
+ # # Now handle only new segments
65
+ # if new_segments:
66
+ # for segment in new_segments:
67
+ # print(f"New Segment: {segment['text']}")
68
  print(f"Transcription: {transcription}")
69
  except Exception as e:
70
  print(f"Error receiving transcription: {e}")
infer.py CHANGED
@@ -164,7 +164,7 @@ def transcribe_core_ws(audio_file, last_transcribed_time):
164
  logging.info(f"Processing segment with start time: {s.start} and end time: {s.end}")
165
 
166
  # Only process segments that start after the last transcribed time
167
- if s.start == last_transcribed_time:
168
  logging.info(f"New segment found starting at {s.start} seconds.")
169
  for w in words:
170
  words.append({'start': w.start, 'end': w.end, 'word': w.word, 'probability': w.probability})
 
164
  logging.info(f"Processing segment with start time: {s.start} and end time: {s.end}")
165
 
166
  # Only process segments that start after the last transcribed time
167
+ if s.start >= last_transcribed_time:
168
  logging.info(f"New segment found starting at {s.start} seconds.")
169
  for w in words:
170
  words.append({'start': w.start, 'end': w.end, 'word': w.word, 'probability': w.probability})