-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_specs_example.txt
More file actions
16 lines (13 loc) · 2.18 KB
/
Copy pathuser_specs_example.txt
File metadata and controls
16 lines (13 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Using Python and FastAPI, you must build an API with 1 endpoint. It is defined below:
1. Transcribe - Accepts an input stream of wav audio data. This endpoint will use Faster Whisper with the repo/model: "deepdml/faster-whisper-large-v3-turbo-ct2". The parameters for this model are below:
- Compute Type: int8_float16.
- Device: "cuda".
As the audio data stream is received, the chunks should be appended to an audio_buffer - which should happen continuously until this API call is complete. FasterWhisper comes bundled with the Silero VAD model for detecting human speech, and this should be used to detect speech. When speech is FIRST detected in the incoming audio stream, a speech_detected boolean should be set to True. From this point on:
- If speech is NOT detected for a continuous period of 200ms or longer, and a boolean called processed is set to false, the audio_buffer data should be transcribed by the model and stored in a result variable. The boolean processed should then be set to true.
- If speech is detected before 800ms of no speech pass: processed should be set to false, and if a transcription is currently in progress, it should be canceled. Audio then continues to be received and appended to the buffer until another 200ms of no speech occurs.
- If 800ms of no speech pass: the last transcription result should be returned to the user as a text response. If the transcription is still going, wait for it, and then return it once completed. At this point, it doesn't matter if speech is detected again.
- If the audio input stream ends at any point, then none of the above speech detection logic applies: the audio_buffer should be passed to the model to transcribe, and - once finished - the result should be returned to the client/user.
Additional API Details:
- Ensure that the model is downloaded into a "models" subdirectory if it doesn't already exist, and load it from there.
- The model should be loaded when the API starts up, and only one instance should be used.
- Access to this API should be by API key - which should be stored in a dict on the server. Handle authentication by API key for the endpoint - returning appropriate errors if not present or correct.