openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

stt microphone live example

Open ChitranshS opened this issue 8 months ago • 0 comments

  • [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:

  1. Captures audio from the microphone in real-time
  2. Streams the audio data to OpenAI's transcription API via WebSockets
  3. Processes and displays transcription events as they occur
  4. Handles speech detection events (speech start/stop)
  5. 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:

  • websockets for WebSocket communication
  • sounddevice for microphone input
  • numpy for audio data processing
  • pydantic for 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.

ChitranshS avatar Mar 24 '25 16:03 ChitranshS