Skip to content

danielksb/chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Bot Project 🤖🎙️

Welcome to the Chat Bot project! This initiative is a simple hobby project designed to explore the capabilities of the OpenAI API for speech-to-text and text-to-speech conversion, along with the code generation capabilities of ChatGPT.

This project enables you to engage in conversations with an OpenAI assistant using your voice and receive spoken responses. It offers a basic web interface for recording and playing audio, enhancing the experience by converting the recorded speech to text through OpenAI.

The majority of the code is AI-generated by ChatGPT, with minor tweaks incorporated here and there.

Introduction

The primary goals of this project include:

  • Recording voice using the browser's Web Audio API.
  • Utilizing the OpenAI API for speech-to-text conversion.
  • Generating a response from an OpenAI assistant to be played back as audio.
  • Experimenting with text-to-speech using the OpenAI API.

Please note that this project is purely for educational and recreational purposes, and its primary intention is to provide a hands-on experience with the OpenAI API. It's a great starting point for those interested in exploring voice-related functionalities and experimenting with API integrations, but not intended for commercial use.

Getting Started

To get started with the project, follow these steps:

Prerequisites

  1. OpenAI API Key: Obtain an API key from OpenAI. You can sign up for an API key on the OpenAI platform.

Installation

  1. Clone the Repository:

    git clone https://github.com/danielksb/chatbot.git
  2. Navigate to the Project Directory:

    cd chatbot
  3. Install Dependencies:

    npm install

Configuration

  1. Set OpenAI API Key:
    • Set the environment variable OPENAI_API_KEY to your actual OpenAI API key.

Run the Application

  1. Start the Server:

    npm start
  2. Access the Application: Open your web browser and go to http://localhost:3000.

Project Structure

Frontend

The frontend code is located in the static directory. It contains the HTML, CSS, and JavaScript files responsible for the user interface and interactions.

Backend

The backend code is primarily written in Express.js and can be found in the main.js file. This file handles server setup, routing, and interaction with the OpenAI API.

Usage

  1. Record Audio:

    • Click the "Record" button to initiate voice recording.
    • Click the "Stop" button to conclude the recording.
  2. Have a Chat with GPT:

    • Automatically convert the recorded speech to text using the OpenAI API.
    • Transmit the text as a message to a preconfigured assistant (currently hardcoded in the backend).
    • Upon the assistant's response, an audio file will be generated and played.
    • Click the "Play" button to replay the recorded audio.
  3. Explore and Experiment:

    • Feel free to customize and expand the project according to your interests.
    • Experiment with various voices and features provided by the OpenAI API.

License

This project is licensed under the GNU Affero GPL.

Happy coding! 🚀

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published