talkedBot.mp4
AIChatVoice is a chatbot application that integrates speech recognition and synthesis with a web-based interface. Built with Node.js, Express, and the OpenAI API, this project provides an interactive experience by converting spoken language into text and delivering vocal responses. The application includes a feature to choose between English and Arabic languages and records user transcripts and AI responses in a MySQL database through a PHP script.
Speech Recognition: Converts spoken input into text.
Speech Synthesis: Reads out AI responses in the chosen language.
Language Selection: Allows users to choose between English and Arabic.
Database Integration: Saves user transcripts and AI responses in a MySQL database.
Web Interface: Provides an intuitive user interface for chatbot interaction.
-
Frontend (
chatbot.html&chatbot.js)chatbot.html: The HTML file that provides the user interface.chatbot.js: JavaScript file that handles speech recognition, sending data to the server, and updating the UI.
-
Backend (
server.js&chatbot.php)server.js: Node.js server using Express that processes the AI responses and interacts with the OpenAI API.chatbot.php: PHP script that handles storing transcripts and AI responses in a MySQL database.
-
Database
- MySQL database with two tables:
chatbotUserfor storing user transcripts andchatbotAifor storing AI responses.
- MySQL database with two tables:
- Node.js and npm
- MySQL
- PHP and a local server environment like XAMPP
-
Install Node.js Dependencies
npm install
-
Configure the PHP Script
- Update
chatbot.phpwith your MySQL database credentials. - Ensure that
chatbot.phpis accessible from your Node.js server.
- Update
-
Create Database and Tables
- Import the SQL schema for creating the
chatbotUserandchatbotAitables.
- Import the SQL schema for creating the
CREATE TABLE chatbotAi (
id INT AUTO_INCREMENT PRIMARY KEY,
response TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE chatbotUser (
id INT AUTO_INCREMENT PRIMARY KEY,
text TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);-
Run the Node.js Server
node server.js
-
Start the PHP Server
Ensure your PHP server is running (e.g., XAMPP or similar).
- Open your web browser and navigate to
http://localhost:3000. - Click the "Start" button to begin speech recognition.
- Speak into your microphone to send a transcript to the server.
- The AI response will be displayed on the screen and read aloud.