This is a web application that allows users to interact with a magical talking pumpkin. The app listens for a "Hey Pumpkin" wake word, transcribes the user's speech to text, generates a response using OpenAI's GPT-4, and then speaks the response back to the user. The mouth is animated using Azure Cognitive Services. This was created to be projected onto a real pumpkin to interact with trick or treaters. In the code the pumpkin is referred to as "Kal" or "Hal".
- Node.js (v18 or higher)
- NPM (v6 or higher)
- An OpenAI API key
- An Azure Cognitive Services API key
For Azure Cognitive Services:
-
Create an Azure Account:
- Go to the Azure Portal.
- Sign up for an account if you don't have one.
-
Create a Speech Service:
- In the Azure Portal, click on "Create a resource."
- Search for "Speech" and select "Speech" from the list.
- Click "Create" and fill in the required details (Subscription, Resource Group, Region, etc.).
- Click "Review + create" and then "Create" to provision the service.
-
Get Your Azure Key and Region:
- After the service is created, go to the resource.
- Under the "Keys and Endpoint" section, you will find your Key and Region.
- Copy these values and add them to your
.env
file as shown below.
Voices can be found here https://speech.microsoft.com/portal/voicegallery
- Clone the repository:
git clone https://github.com/ephemeralwaves/talking_pumpkin.git
cd talking_pumpkin
- Install the dependencies:
npm install
- Create a
.env
file in theserver/config
directory with your OpenAI API key:
OPENAI_API_KEY=your_openai_api_key_here
AZURE_SPEECH_KEY=your_azure_speech_key_here
AZURE_REGION=your_azure_region_here
To run the server with HTTPS, you will need to generate the necessary .pem
files: key.pem
, csr.pem
, and cert.pem
. Follow the instructions below to create these files.
-
Prerequisites
Make sure you have OpenSSL installed on your system. You can check if it's installed by running:
openssl version
If OpenSSL is not installed, you can download and install it from OpenSSL's official website.
-
Generating a Private Key (
key.pem
)To generate a private key in PEM format, use the following command:
openssl genpkey -algorithm RSA -out key.pem -pkeyopt rsa_keygen_bits:2048
- This command generates a 2048-bit RSA private key and saves it to
key.pem
.
- This command generates a 2048-bit RSA private key and saves it to
-
Generating a Certificate Signing Request (
csr.pem
)Once you have the private key, you can generate a certificate signing request (CSR) using the following command:
openssl req -new -key key.pem -out csr.pem
- This command will prompt you for information such as country, state, organization, and common name (domain name). The generated CSR will be saved as
csr.pem
.
- This command will prompt you for information such as country, state, organization, and common name (domain name). The generated CSR will be saved as
-
Generating a Self-Signed Certificate (
cert.pem
)If you need a self-signed certificate for testing purposes, you can generate one using the following command:
openssl req -new -x509 -key key.pem -out cert.pem -days 365
- This command uses the private key from
key.pem
to create a self-signed certificate valid for 365 days, saved ascert.pem
.
- This command uses the private key from
-
Place the
.pem
Files Ensure that the generated.pem
files (key.pem
andcert.pem
) are placed in the root directory of your server or in a designated secure directory. -
Update the Server Code
In your
server/index.js
file, ensure that the options for HTTPS are set to read the.pem
files correctly:const fs = require('fs'); const https = require('https'); const options = { key: fs.readFileSync('key.pem'), cert: fs.readFileSync('cert.pem') }; const server = https.createServer(options, app);
-
Build the client-side code: The client-side code needs to be built before the app can be run. To do this, run the following command in your terminal:
npm run build
- Start the server:
npm start
or HOST=0.0.0.0 npm start if running on another machine.
- Access the app: Open your web browser and navigate to http://localhost:3000 (or whatever port your Express server is configured to use). You should see the Talking Pumpkin web app.
- Click the "Activate" button to begin listening for the wake word.
- Say "Hey Pumpkin" to activate the AI.
- Ask your question or give a command.
- Wait for the pumpkin to respond.
- Click the "Deactivate" button when you're done.
GPL v3.0