Spaces:
Sleeping
Sleeping
AshDavid12
commited on
Commit
·
1ab0cdf
1
Parent(s):
7456852
forgot var change in delete
Browse files
client.py
CHANGED
@@ -13,15 +13,15 @@ async def send_audio(websocket):
|
|
13 |
buffer_size = 1024 * 16 # Send smaller chunks (16KB) for real-time processing
|
14 |
|
15 |
# Download the WAV file locally
|
16 |
-
with requests.get(AUDIO_FILE_URL, stream=True) as response:
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
|
23 |
# Open the downloaded WAV file and extract PCM data
|
24 |
-
with wave.open('
|
25 |
metadata = {
|
26 |
'sample_rate': wav_file.getframerate(),
|
27 |
'channels': wav_file.getnchannels(),
|
|
|
13 |
buffer_size = 1024 * 16 # Send smaller chunks (16KB) for real-time processing
|
14 |
|
15 |
# Download the WAV file locally
|
16 |
+
# with requests.get(AUDIO_FILE_URL, stream=True) as response:
|
17 |
+
# if response.status_code == 200:
|
18 |
+
# with open('downloaded_audio.wav', 'wb') as f:
|
19 |
+
# for chunk in response.iter_content(chunk_size=1024):
|
20 |
+
# f.write(chunk)
|
21 |
+
# print("Audio file downloaded successfully.")
|
22 |
|
23 |
# Open the downloaded WAV file and extract PCM data
|
24 |
+
with wave.open('test_copy.wav', 'rb') as wav_file:
|
25 |
metadata = {
|
26 |
'sample_rate': wav_file.getframerate(),
|
27 |
'channels': wav_file.getnchannels(),
|
infer.py
CHANGED
@@ -260,9 +260,9 @@ async def websocket_transcribe(websocket: WebSocket):
|
|
260 |
await websocket.send_json(response)
|
261 |
|
262 |
# Optionally delete the temporary WAV file after processing
|
263 |
-
if os.path.exists(
|
264 |
-
os.remove(
|
265 |
-
logging.info(f"Temporary WAV file {
|
266 |
|
267 |
except WebSocketDisconnect:
|
268 |
logging.info("WebSocket connection closed by the client.")
|
|
|
260 |
await websocket.send_json(response)
|
261 |
|
262 |
# Optionally delete the temporary WAV file after processing
|
263 |
+
if os.path.exists(temp_wav_file):
|
264 |
+
os.remove(temp_wav_file)
|
265 |
+
logging.info(f"Temporary WAV file {temp_wav_file} removed.")
|
266 |
|
267 |
except WebSocketDisconnect:
|
268 |
logging.info("WebSocket connection closed by the client.")
|