WYN-Voice: A Conversational AI and Audio Processing Library
Introduction and Motivation
🎙️ WYN-Voice is a Python library designed to simplify the process of creating conversational AI applications that leverage OpenAI's GPT models. 🤖 The library provides an easy-to-use interface for generating responses to user inputs and includes functionality for recording and processing audio, 🎧 making it suitable for building interactive voice-based applications. 🗣️
Directory Structure
The project directory is organized as follows:
.
├── pyproject.toml
├── README.md
└── wyn_voice
└── chat.py
pyproject.toml: Contains the project's dependencies and other configuration settings.README.md: This file, providing an overview and usage instructions.wyn_voice: A folder containing the main library code.chat.py: The script defining theChatBotandAudioProcessorclasses.
Example Usage
To get started with Wyn Voice, follow these steps:
Installation
First, install the necessary packages using pip:
pip install wyn-voice pyautogen pydub openai
Using the ChatBot Class
The ChatBot class allows you to interact with OpenAI's GPT models to generate responses based on user input.
from wyn_voice.chat import ChatBot
# Initialize the ChatBot with your OpenAI API key
api_key = 'your-openai-api-key'
chatbot = ChatBot(api_key)
# Generate a response from the chatbot
prompt = "Hello, how are you?"
response = chatbot.generate_response(prompt)
print("ChatBot:", response)
# Retrieve the conversation history
history = chatbot.get_history()
print("Conversation History:", history)
Using the AudioProcessor Class
The AudioProcessor class provides functionality to record audio, process it, and interact with the ChatBot.
from wyn_voice.chat import ChatBot, AudioProcessor
# Initialize the ChatBot with your OpenAI API key
api_key = 'your-openai-api-key'
chatbot = ChatBot(api_key)
# Initialize the AudioProcessor with the ChatBot
audio_processor = AudioProcessor(chatbot)
# Record audio and generate a response
transcript = audio_processor.process_audio_and_generate_response()
print("Transcript:", transcript)
# Record audio and get the transcribed text
text = audio_processor.voice_to_text()
print("Transcribed Text:", text)
# Convert text to speech and save it as an mp3 file
response_text = "This is a test response."
output_file = audio_processor.text_to_voice(response_text)
print("Saved audio response to:", output_file)
# Play the saved audio file
audio_processor.play_audio(output_file)
Using the ChatEnvironment Class
The ChatEnvironment class allows you to create a conversation environment to interact with ChatBot using voice command.
from wyn_voice.chat import ChatBot, AudioProcessor, ChatEnvironment
from google.colab import userdata
OPENAI_API_KEY = userdata.get('OPENAI_API_KEY')
# Create instances of ChatBot and AudioProcessor
chatbot = ChatBot(
api_key=OPENAI_API_KEY,
protocol="You are a live translator."
"When you hear Chinese, speak English."
"When you hear English, speak Chinese.")
audio_processor = AudioProcessor(chatbot)
# Create an instance of ChatEnvironment
chat_env = ChatEnvironment(chatbot, audio_processor)
# Start the chat loop
chat_env.start_chat(exit_command="Exit the program")
Author
Yiqiao Yin
Site
Metadata
Release files for wyn-voice 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wyn_voice-0.2.3.tar.gz | 5.1 kB | Without provenance | Details for wyn_voice-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wyn_voice-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for wyn_voice-0.2.3-py3-none-any.whl |
Total release size: 10.6 kB
Release files / wyn_voice-0.2.3.tar.gz
| Download URL | wyn_voice-0.2.3.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
583705870c0263835080442141cc91b6ebab80faea64f501c7699689a0e3a972
|
|
BLAKE2b-256 checksum How to use checksums |
06658d414c55cabf08e885362fddf7a2c5c04a05eabf39bba49b16f19cb0bfca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.13 Windows/10
|
Release files / wyn_voice-0.2.3-py3-none-any.whl
| Download URL | wyn_voice-0.2.3-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cc2810d4962ac308a664798e3436f8e73f425c486c8952ba5d7dbef5961424b
|
|
BLAKE2b-256 checksum How to use checksums |
ef7172d3d70c4e0dc303c33c7e34367b47fd8f9fac40fa5813a8061945f46cd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.13 Windows/10
|
Security for wyn-voice 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.