AshDavid12 commited on
Commit
8004cea
·
1 Parent(s): 1c789c0

added more logs

Browse files
Files changed (2) hide show
  1. client.py +7 -1
  2. infer.py +3 -1
client.py CHANGED
@@ -6,6 +6,11 @@ import wave
6
  import websockets
7
  import requests
8
  import ssl
 
 
 
 
 
9
 
10
  # Parameters for reading and sending the audio
11
  AUDIO_FILE_URL = "https://raw.githubusercontent.com/AshDavid12/runpod-serverless-forked/main/test_hebrew.wav" # Use WAV file
@@ -35,6 +40,7 @@ def convert_to_mono_16k(audio_file_path):
35
 
36
 
37
  async def send_audio(websocket):
 
38
  buffer_size = 1024 * 16 # Send smaller chunks (16KB) for real-time processing
39
  logging.info("Converting the audio to mono and 16kHz.")
40
 
@@ -60,7 +66,7 @@ async def send_audio(websocket):
60
  for i in range(0, len(raw_data), buffer_size):
61
  pcm_chunk = raw_data[i:i + buffer_size]
62
  await websocket.send(pcm_chunk) # Send raw PCM data chunk
63
- logging.info(f"Sent PCM chunk of size {len(pcm_chunk)} bytes.")
64
  await asyncio.sleep(0.01) # Simulate real-time sending
65
 
66
  logging.info("Completed sending all audio data.")
 
6
  import websockets
7
  import requests
8
  import ssl
9
+ import sys
10
+
11
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s',
12
+ handlers=[logging.StreamHandler(sys.stdout)], force=True)
13
+ logger = logging.getLogger(__name__)
14
 
15
  # Parameters for reading and sending the audio
16
  AUDIO_FILE_URL = "https://raw.githubusercontent.com/AshDavid12/runpod-serverless-forked/main/test_hebrew.wav" # Use WAV file
 
40
 
41
 
42
  async def send_audio(websocket):
43
+ print(f"hi")
44
  buffer_size = 1024 * 16 # Send smaller chunks (16KB) for real-time processing
45
  logging.info("Converting the audio to mono and 16kHz.")
46
 
 
66
  for i in range(0, len(raw_data), buffer_size):
67
  pcm_chunk = raw_data[i:i + buffer_size]
68
  await websocket.send(pcm_chunk) # Send raw PCM data chunk
69
+ #logging.info(f"Sent PCM chunk of size {len(pcm_chunk)} bytes.")
70
  await asyncio.sleep(0.01) # Simulate real-time sending
71
 
72
  logging.info("Completed sending all audio data.")
infer.py CHANGED
@@ -225,6 +225,8 @@ async def websocket_transcribe(websocket: WebSocket):
225
 
226
  # A buffer to store raw PCM audio data
227
  pcm_audio_buffer = bytearray()
 
 
228
 
229
  # Metadata for the incoming PCM data (sample rate, channels, and sample width should be consistent)
230
  sample_rate = 16000 # 16kHz
@@ -236,7 +238,7 @@ async def websocket_transcribe(websocket: WebSocket):
236
  if not os.path.exists(tmp_directory):
237
  logging.info(f"Creating /tmp directory: {tmp_directory}")
238
  os.makedirs(tmp_directory)
239
-
240
  while True:
241
  try:
242
  # Receive the next chunk of PCM audio data
 
225
 
226
  # A buffer to store raw PCM audio data
227
  pcm_audio_buffer = bytearray()
228
+ logging.info("im here, is it failing?.")
229
+
230
 
231
  # Metadata for the incoming PCM data (sample rate, channels, and sample width should be consistent)
232
  sample_rate = 16000 # 16kHz
 
238
  if not os.path.exists(tmp_directory):
239
  logging.info(f"Creating /tmp directory: {tmp_directory}")
240
  os.makedirs(tmp_directory)
241
+ logging.info("im here, is it failing?2.")
242
  while True:
243
  try:
244
  # Receive the next chunk of PCM audio data