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

change base64 type

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -16,12 +16,14 @@ async def process_audio_stream(audio_path, max_tokens):
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({
 
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)
20
+ # Convert to string for writing to text file
21
+ base64_string = base64_bytes.decode('utf-8')
22
 
23
  # Connect to WebSocket
24
  async with websockets.connect('ws://nexa-omni.nexa4ai.com/ws/process-audio/') as websocket:
25
  # Send binary base64 audio data
26
+ await websocket.send(base64_string) # Send as raw bytes
27
 
28
  # Send parameters as JSON string
29
  await websocket.send(json.dumps({