Skip to main content

This library provides audio interface with OpenAI endpoint.

Project description

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 the ChatBot and AudioProcessor classes.

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)

Author

Yiqiao Yin

Site

https://www.y-yin.io/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wyn_voice-0.1.12.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wyn_voice-0.1.12-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file wyn_voice-0.1.12.tar.gz.

File metadata

  • Download URL: wyn_voice-0.1.12.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for wyn_voice-0.1.12.tar.gz
Algorithm Hash digest
SHA256 a82179b341ca84d171aa3a1d9d6d42a358c742ee84747ac3b57754ae998fcdf8
MD5 7d30c42fefabb00a6072c5d3cbb796d5
BLAKE2b-256 51a600d4c60ba5de06634b766bfa48a0faaddbe4bf4e4c5ee0fb0c8330701d46

See more details on using hashes here.

File details

Details for the file wyn_voice-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: wyn_voice-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.9.13 Windows/10

File hashes

Hashes for wyn_voice-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 8d43b39fc2d6d27665fb815e7e2f9fdd06d257b9360f44f6456442d1a0d695bf
MD5 c2f4f24d670ab51080f7eac3853b716e
BLAKE2b-256 dde6523c1f4a6c98dbcb89d20596419a9ce1d5ac0802f369300f8c827c2f72cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page