https://github.com/syed007hassan/openai-assistants-with-streaming
A voice assistant using OpenAI Assistants API with stream enabled that can use Code Interpreter.
https://github.com/syed007hassan/openai-assistants-with-streaming
Last synced: 5 months ago
JSON representation
A voice assistant using OpenAI Assistants API with stream enabled that can use Code Interpreter.
- Host: GitHub
- URL: https://github.com/syed007hassan/openai-assistants-with-streaming
- Owner: Syed007Hassan
- Created: 2024-07-06T16:37:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-06T17:12:52.000Z (over 1 year ago)
- Last Synced: 2025-02-17T21:46:33.052Z (8 months ago)
- Language: Python
- Homepage:
- Size: 679 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Language Translation Assistant
This project is a Language Translation Assistant using OpenAI's API and PyAudio. It captures audio from a microphone, transcribes it, sends the transcription to an assistant, receives a response, and converts the response to speech.
## Features
- **Audio Capture**: Records audio using PyAudio.
- **Silence Detection**: Ensures only significant audio is processed.
- **Speech-to-Text**: Uses OpenAI's Whisper model to transcribe audio.
- **Language Translation**: Sends transcriptions to an assistant for translation.
- **Text-to-Speech**: Converts assistant's responses to audio and plays them back.## Installation
1. **Clone the repository**:
```sh
git clone https://github.com/yourusername/language-translation-assistant.git
cd language-translation-assistant
```2. **Create a virtual environment**:
```sh
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
```3. **Install dependencies**:
```sh
pip install -r requirements.txt
```4. **Set up environment variables**:
Create a `.env` file in the project root and add your OpenAI Assistant ID:
```sh
ASSISTANT_ID=your_assistant_id
OPENAI_API_KEY=sk-xxxx
```## Usage
1. **Run the main script**:
```sh
python main.py
```2. **Interact with the assistant**:
- Speak into the microphone.
- The assistant will transcribe, translate, and respond in audio.## Customization
- **Adjust recording settings**:
Modify the `CHUNK`, `FORMAT`, `CHANNELS`, `RATE`, and `RECORD_SECONDS` constants to change the audio recording parameters.
- **Silence threshold**:
Adjust the `SILENCE_THRESHOLD` to change the sensitivity of silence detection.## Dependencies
- `pyaudio`
- `wave`
- `numpy`
- `pydub`
- `python-dotenv`
- `openai`## Contributing
Contributions are welcome! Please open an issue or submit a pull request.