Spaces:
Sleeping
Sleeping
AshDavid12
commited on
Commit
·
abaf442
1
Parent(s):
55b37bf
wss to http for url
Browse files
client.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import asyncio
|
|
|
|
|
2 |
import websockets
|
3 |
import requests
|
4 |
import ssl
|
@@ -22,7 +24,7 @@ async def send_audio(websocket):
|
|
22 |
# Send buffered audio data once it's large enough
|
23 |
if len(audio_buffer) >= buffer_size:
|
24 |
await websocket.send(audio_buffer)
|
25 |
-
print(f"Sent {len(audio_buffer)} bytes of audio data.")
|
26 |
audio_buffer.clear()
|
27 |
await asyncio.sleep(0.01)
|
28 |
|
@@ -35,6 +37,7 @@ async def receive_transcription(websocket):
|
|
35 |
try:
|
36 |
transcription = await websocket.recv() # Receive transcription from the server
|
37 |
print(f"Transcription: {transcription}")
|
|
|
38 |
download_url = transcription.get('download_url')
|
39 |
if download_url:
|
40 |
print(f"Download URL: {download_url}")
|
|
|
1 |
import asyncio
|
2 |
+
import json
|
3 |
+
|
4 |
import websockets
|
5 |
import requests
|
6 |
import ssl
|
|
|
24 |
# Send buffered audio data once it's large enough
|
25 |
if len(audio_buffer) >= buffer_size:
|
26 |
await websocket.send(audio_buffer)
|
27 |
+
#print(f"Sent {len(audio_buffer)} bytes of audio data.")
|
28 |
audio_buffer.clear()
|
29 |
await asyncio.sleep(0.01)
|
30 |
|
|
|
37 |
try:
|
38 |
transcription = await websocket.recv() # Receive transcription from the server
|
39 |
print(f"Transcription: {transcription}")
|
40 |
+
transcription = json.loads(transcription)
|
41 |
download_url = transcription.get('download_url')
|
42 |
if download_url:
|
43 |
print(f"Download URL: {download_url}")
|
infer.py
CHANGED
@@ -229,7 +229,7 @@ async def websocket_transcribe(websocket: WebSocket):
|
|
229 |
response = {
|
230 |
"new_segments": partial_result['new_segments'],
|
231 |
"processed_segments": processed_segments,
|
232 |
-
"download_url": f"
|
233 |
}
|
234 |
logging.info(f"Sending {len(partial_result['new_segments'])} new segments to the client.")
|
235 |
await websocket.send_json(response)
|
|
|
229 |
response = {
|
230 |
"new_segments": partial_result['new_segments'],
|
231 |
"processed_segments": processed_segments,
|
232 |
+
"download_url": f"https://gigaverse-ivrit-ai-streaming.hf.space/download_audio/{temp_audio_filename}"
|
233 |
}
|
234 |
logging.info(f"Sending {len(partial_result['new_segments'])} new segments to the client.")
|
235 |
await websocket.send_json(response)
|