PerryCheng614 commited on
Commit
42234b9
1 Parent(s): 7fb94ea

changed websocket data type

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -13,19 +13,17 @@ async def process_audio_stream(audio_path, max_tokens):
13
  return
14
 
15
  try:
16
- # Read audio file and convert to base64
17
  with open(audio_path, 'rb') as f:
18
  audio_bytes = f.read()
19
- base64_bytes = base64.b64encode(audio_bytes)
20
- # Convert to binary for websocket
21
- binary_data = base64_bytes
22
 
23
  # Connect to WebSocket
24
  async with websockets.connect('ws://nexa-omni.nexa4ai.com/ws/process-audio/') as websocket:
25
- # Send base64 encoded audio data
26
- await websocket.send(binary_data)
27
 
28
- # Send parameters
29
  await websocket.send(json.dumps({
30
  "prompt": "",
31
  "max_tokens": max_tokens
 
13
  return
14
 
15
  try:
16
+ # Read audio file and convert to base64 bytes
17
  with open(audio_path, 'rb') as f:
18
  audio_bytes = f.read()
19
+ base64_bytes = base64.b64encode(audio_bytes) # base64 encoded bytes
 
 
20
 
21
  # Connect to WebSocket
22
  async with websockets.connect('ws://nexa-omni.nexa4ai.com/ws/process-audio/') as websocket:
23
+ # Send binary base64 audio data
24
+ await websocket.send(base64_bytes) # Send as raw bytes
25
 
26
+ # Send parameters as JSON string
27
  await websocket.send(json.dumps({
28
  "prompt": "",
29
  "max_tokens": max_tokens