Skip to main content

Get an audio response from ChatGPT

Project description

PyAudioAI Python Library

Build and Test

The Python library combines the OpenAI ChatGPT API with audio input and output. With this, questions can be recorded as audio, sent to ChatGPT and the answer from ChatGPT can be output as audio again. For the audio output, gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate's text-to-speech API is used.

Installation

You don't need this source code unless you want to modify the package. If you just want to use the package, just run:

pip install pyaudioai

Install from source with:

python setup.py install

Usage

Portaudio needs to be configured to have access to your computers microphone.

Linux:

sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0

Mac OS X:

brew install portaudio

Windows:

pip install pipwin
pipwin install pyaudio

The OpenAI library needs to be configured with your account's secret key OPENAI_API_KEY which is available on the website.

Example:

import os
import pyaudioai

audio_file = "question.wav" # question can be saved
question_audio = pyaudioai.RecordQuestion(5, audio_file)
question_audio.record()

response_class = pyaudioai.OpenAiResponse("<OPENAI_API_KEY>")
response_class.get_audio_response(audio_file)

question_audio.delete_file() # delete question audio if required

Developer Documentation

The documentation of the source code for contributors can be found here.

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

pyaudioai-0.0.2.tar.gz (5.3 kB view hashes)

Uploaded Source

Built Distribution

pyaudioai-0.0.2-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

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