# Streamlit Voice Pipeline
A Streamlit-ready voice pipeline for real-time conversation with OpenAI's GPT-4o Realtime API. Build voice-enabled Streamlit applications with minimal setup!
## Features
- đ¤ **Real-time voice conversation** with OpenAI's GPT-4o
- đ **Automatic reconnection** on connection drops
- đą **Streamlit-optimized** with session state integration
- đ¨ **Customizable voices** and speech parameters
- đ **Conversation transcripts** and history
- ⥠**Thread-safe** and production-ready
- đ ī¸ **Easy callbacks** for transcripts, errors, and status changes
## Installation
```bash
pip install streamlit-voice-pipeline
```
## Quick Start
```python
import streamlit as st
from streamlit_voice_pipeline import get_or_create_pipeline
st.title("đ¤ Voice Chat with AI")
# Initialize pipeline
pipeline = get_or_create_pipeline(
api_key="your-openai-api-key",
voice="alloy" # Options: alloy, echo, fable, onyx, nova, shimmer, verse
)
# Control buttons
col1, col2 = st.columns(2)
with col1:
if st.button("đ¤ Start Voice Chat"):
pipeline.start()
st.success("Started!")
with col2:
if st.button("âšī¸ Stop"):
pipeline.stop()
st.info("Stopped")
# Show status
st.write(f"**Status:** {pipeline.get_status()}")
# Display conversation
transcripts = pipeline.get_transcripts()
for transcript in transcripts:
st.write(f"**{transcript['role'].title()}:** {transcript['content']}")
```
## Advanced Usage
### With Callbacks
```python
def on_transcript(text):
st.session_state.messages.append(text)
def on_error(error):
st.error(f"Error: {error}")
def on_status_change(status):
st.session_state.status = status
pipeline = get_or_create_pipeline(
api_key="your-key",
voice="echo",
temperature=0.8,
max_tokens=800,
on_transcript=on_transcript,
on_error=on_error,
on_status_change=on_status_change
)
```
### Configuration Options
```python
pipeline = StreamlitVoicePipeline(
api_key="your-openai-api-key",
model="gpt-4o-realtime-preview-2025-06-03",
voice="alloy", # Voice selection
temperature=0.8, # Response creativity (0.0-1.0)
max_tokens=800, # Maximum response length
sample_rate=24000, # Audio quality (16000/24000/48000)
vad_threshold=0.7, # Voice detection sensitivity
silence_duration=1200, # Silence before stopping (ms)
)
```
## Available Voices
- **alloy** - Neutral, balanced
- **echo** - Expressive, dynamic
- **fable** - Warm, storytelling
- **onyx** - Deep, authoritative
- **nova** - Youthful, energetic
- **shimmer** - Gentle, soft
- **verse** - Conversational, friendly
## Status Values
- `stopped` - Pipeline not running
- `connecting` - Establishing connection
- `connected` - Connected to API
- `ready` - Ready for conversation
- `listening` - Waiting for user speech
- `user_speaking` - User is talking
- `processing` - Processing user input
- `ai_speaking` - AI is responding
- `error` - Error occurred
## Requirements
- Python 3.8+
- OpenAI API key with Realtime API access
- Microphone and speakers/headphones
- Internet connection
## Example Applications
Check out the `/examples` directory for:
- Basic voice chat app
- Advanced configuration demo
- Integration with other Streamlit components
## Troubleshooting
### Common Issues
**"No microphone detected"**
```bash
# Linux
sudo apt-get install portaudio19-dev python3-pyaudio
# macOS
brew install portaudio
pip install pyaudio
# Windows
pip install pipwin
pipwin install pyaudio
```
**"WebSocket connection failed"**
- Check your OpenAI API key
- Ensure you have Realtime API access
- Verify internet connection
**"Audio feedback/echo"**
- Use headphones instead of speakers
- Adjust `vad_threshold` parameter
- Check microphone sensitivity
## Contributing
Contributions welcome! Please read our contributing guidelines and submit PRs.
## License
MIT License - see LICENSE file for details.
## Support
- đ [Documentation](https://github.com/yourusername/streamlit-voice-pipeline)
- đ [Bug Reports](https://github.com/yourusername/streamlit-voice-pipeline/issues)
- đŦ [Discussions](https://github.com/yourusername/streamlit-voice-pipeline/discussions)
---
Built with â¤ī¸ for the Streamlit community
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/streamlit-voice-pipeline",
"name": "streamlit-voice-pipeline",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Your Name <your.email@example.com>",
"keywords": "streamlit, voice, openai, realtime, audio, speech, gpt-4o, conversation, ai",
"author": "Your Name",
"author_email": "Your Name <your.email@example.com>",
"download_url": "https://files.pythonhosted.org/packages/69/3e/92102dc028faf6bdc6868b76ebb6a73dc24c6a5448c0cfd3e20ff35896fe/streamlit_voice_pipeline-1.0.0.tar.gz",
"platform": null,
"description": "# Streamlit Voice Pipeline\n\nA Streamlit-ready voice pipeline for real-time conversation with OpenAI's GPT-4o Realtime API. Build voice-enabled Streamlit applications with minimal setup!\n\n## Features\n\n- \ud83c\udfa4 **Real-time voice conversation** with OpenAI's GPT-4o\n- \ud83d\udd04 **Automatic reconnection** on connection drops\n- \ud83d\udcf1 **Streamlit-optimized** with session state integration\n- \ud83c\udfa8 **Customizable voices** and speech parameters\n- \ud83d\udcdd **Conversation transcripts** and history\n- \u26a1 **Thread-safe** and production-ready\n- \ud83d\udee0\ufe0f **Easy callbacks** for transcripts, errors, and status changes\n\n## Installation\n\n```bash\npip install streamlit-voice-pipeline\n```\n\n## Quick Start\n\n```python\nimport streamlit as st\nfrom streamlit_voice_pipeline import get_or_create_pipeline\n\nst.title(\"\ud83c\udfa4 Voice Chat with AI\")\n\n# Initialize pipeline\npipeline = get_or_create_pipeline(\n api_key=\"your-openai-api-key\",\n voice=\"alloy\" # Options: alloy, echo, fable, onyx, nova, shimmer, verse\n)\n\n# Control buttons\ncol1, col2 = st.columns(2)\nwith col1:\n if st.button(\"\ud83c\udfa4 Start Voice Chat\"):\n pipeline.start()\n st.success(\"Started!\")\n\nwith col2:\n if st.button(\"\u23f9\ufe0f Stop\"):\n pipeline.stop()\n st.info(\"Stopped\")\n\n# Show status\nst.write(f\"**Status:** {pipeline.get_status()}\")\n\n# Display conversation\ntranscripts = pipeline.get_transcripts()\nfor transcript in transcripts:\n st.write(f\"**{transcript['role'].title()}:** {transcript['content']}\")\n```\n\n## Advanced Usage\n\n### With Callbacks\n\n```python\ndef on_transcript(text):\n st.session_state.messages.append(text)\n \ndef on_error(error):\n st.error(f\"Error: {error}\")\n \ndef on_status_change(status):\n st.session_state.status = status\n\npipeline = get_or_create_pipeline(\n api_key=\"your-key\",\n voice=\"echo\",\n temperature=0.8,\n max_tokens=800,\n on_transcript=on_transcript,\n on_error=on_error,\n on_status_change=on_status_change\n)\n```\n\n### Configuration Options\n\n```python\npipeline = StreamlitVoicePipeline(\n api_key=\"your-openai-api-key\",\n model=\"gpt-4o-realtime-preview-2025-06-03\",\n voice=\"alloy\", # Voice selection\n temperature=0.8, # Response creativity (0.0-1.0)\n max_tokens=800, # Maximum response length\n sample_rate=24000, # Audio quality (16000/24000/48000)\n vad_threshold=0.7, # Voice detection sensitivity\n silence_duration=1200, # Silence before stopping (ms)\n)\n```\n\n## Available Voices\n\n- **alloy** - Neutral, balanced\n- **echo** - Expressive, dynamic \n- **fable** - Warm, storytelling\n- **onyx** - Deep, authoritative\n- **nova** - Youthful, energetic\n- **shimmer** - Gentle, soft\n- **verse** - Conversational, friendly\n\n## Status Values\n\n- `stopped` - Pipeline not running\n- `connecting` - Establishing connection\n- `connected` - Connected to API \n- `ready` - Ready for conversation\n- `listening` - Waiting for user speech\n- `user_speaking` - User is talking\n- `processing` - Processing user input\n- `ai_speaking` - AI is responding\n- `error` - Error occurred\n\n## Requirements\n\n- Python 3.8+\n- OpenAI API key with Realtime API access\n- Microphone and speakers/headphones\n- Internet connection\n\n## Example Applications\n\nCheck out the `/examples` directory for:\n- Basic voice chat app\n- Advanced configuration demo \n- Integration with other Streamlit components\n\n## Troubleshooting\n\n### Common Issues\n\n**\"No microphone detected\"**\n```bash\n# Linux\nsudo apt-get install portaudio19-dev python3-pyaudio\n\n# macOS \nbrew install portaudio\npip install pyaudio\n\n# Windows\npip install pipwin\npipwin install pyaudio\n```\n\n**\"WebSocket connection failed\"**\n- Check your OpenAI API key\n- Ensure you have Realtime API access\n- Verify internet connection\n\n**\"Audio feedback/echo\"**\n- Use headphones instead of speakers\n- Adjust `vad_threshold` parameter\n- Check microphone sensitivity\n\n## Contributing\n\nContributions welcome! Please read our contributing guidelines and submit PRs.\n\n## License\n\nMIT License - see LICENSE file for details.\n\n## Support\n\n- \ud83d\udcd6 [Documentation](https://github.com/yourusername/streamlit-voice-pipeline)\n- \ud83d\udc1b [Bug Reports](https://github.com/yourusername/streamlit-voice-pipeline/issues) \n- \ud83d\udcac [Discussions](https://github.com/yourusername/streamlit-voice-pipeline/discussions)\n\n---\n\nBuilt with \u2764\ufe0f for the Streamlit community\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Streamlit-ready voice pipeline for real-time conversation with OpenAI's GPT-4o Realtime API",
"version": "1.0.0",
"project_urls": {
"Bug Tracker": "https://github.com/yourusername/streamlit-voice-pipeline/issues",
"Documentation": "https://github.com/yourusername/streamlit-voice-pipeline/blob/main/README.md",
"Homepage": "https://github.com/yourusername/streamlit-voice-pipeline",
"Repository": "https://github.com/yourusername/streamlit-voice-pipeline.git"
},
"split_keywords": [
"streamlit",
" voice",
" openai",
" realtime",
" audio",
" speech",
" gpt-4o",
" conversation",
" ai"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "ecadaf684e1d1d2b4b3ab8ad6176bb92628d62017878a6231bb745a565d769b6",
"md5": "a472b0ddf9d39ce5824720f30743b75a",
"sha256": "f851cbe549621013bb1fa36c71a7815f48e24ffd5495489f60b4512c9bd6f4f2"
},
"downloads": -1,
"filename": "streamlit_voice_pipeline-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a472b0ddf9d39ce5824720f30743b75a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 12388,
"upload_time": "2025-08-16T08:01:26",
"upload_time_iso_8601": "2025-08-16T08:01:26.197189Z",
"url": "https://files.pythonhosted.org/packages/ec/ad/af684e1d1d2b4b3ab8ad6176bb92628d62017878a6231bb745a565d769b6/streamlit_voice_pipeline-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "693e92102dc028faf6bdc6868b76ebb6a73dc24c6a5448c0cfd3e20ff35896fe",
"md5": "f351f0c4176ec422accf2a0e97046c8d",
"sha256": "355530e80c9b412e90d0c875c02e6adbbc1508d32297ec30f0703a0d9c9c919b"
},
"downloads": -1,
"filename": "streamlit_voice_pipeline-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "f351f0c4176ec422accf2a0e97046c8d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 13536,
"upload_time": "2025-08-16T08:01:27",
"upload_time_iso_8601": "2025-08-16T08:01:27.815938Z",
"url": "https://files.pythonhosted.org/packages/69/3e/92102dc028faf6bdc6868b76ebb6a73dc24c6a5448c0cfd3e20ff35896fe/streamlit_voice_pipeline-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-16 08:01:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "streamlit-voice-pipeline",
"github_not_found": true,
"lcname": "streamlit-voice-pipeline"
}