-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Problem
Currently, the /transcribe endpoint uses request.stream.read(),
susi_translator/flask/transcribe_server.py
Line 301 in 96848b5
| chunk = request.stream.read(2048000) |
it assumes a continuous stream of data. This makes it difficult to interface with standard JSON-based clients
susi_translator/flask/audio_grabber.html
Lines 171 to 186 in 96848b5
| const data = { chunk_id: chunkId, audio_b64: base64data }; | |
| // construct the URL from the host and port | |
| const serverhost = document.getElementById('serverhost').value; | |
| const serverport = document.getElementById('serverport').value; | |
| const transcribeurl = `http://${serverhost}:${serverport}/transcribe`; | |
| const csrftoken = getCookie('csrftoken'); | |
| fetch(transcribeurl, { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify(data) | |
| }) | |
| .then(response => { | |
| if (response.ok) { | |
| console.log(`Sent chunk ${chunkId} with ${buffer.length} samples`); |
and can lead to JSONDecodeError if the stream chunks don't align perfectly with JSON boundaries.
Solution
Update the endpoint to handle standard application/json POST requests using Flask’s get_json(). This ensures immediate response to the client while the background thread processes the queue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels