openai-python
openai-python copied to clipboard
stt microphone live example
- [x] I understand that this repository is auto-generated and my pull request may not be merged
Changes being requested
This PR adds a real-time speech-to-text example script demonstrating how to use OpenAI's WebSocket-based transcription API. The script:
- Captures audio from the microphone in real-time
- Streams the audio data to OpenAI's transcription API via WebSockets
- Processes and displays transcription events as they occur
- Handles speech detection events (speech start/stop)
- Properly manages resources and connections
This example would be valuable for users who want to implement real-time transcription functionality in their applications using the OpenAI API.
Additional context & links
This implementation uses:
websocketsfor WebSocket communicationsounddevicefor microphone inputnumpyfor audio data processingpydanticfor data validation and configuration
The script demonstrates best practices for real-time audio streaming and event handling with OpenAI's transcription API, including proper connection management, error handling, and resource cleanup.