Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
CursedPrograms committed Feb 12, 2024
1 parent 0462190 commit 2cd8b63
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ key/

models/
training_data/
unprocessed_images

# PyInstaller
dist/
build/
main.spec/
Expand Down
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pyaudio==0.2.14
pydub==0.25.1
beautifulsoup4==4.10.0
SpeechRecognition==3.10.1
pygame==2.5.2
```
<br>

Expand Down
13 changes: 9 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import os
import time
import subprocess
import speech_recognition as sr
from gtts import gTTS
import json
from scripts.play_audio import play_audio

def read_config():
with open('settings.json', 'r') as config_file:
Expand All @@ -14,11 +16,14 @@ def greet_user():
robot_name = config.get("robot_name", "")
print(f"Welcome to {robot_name}.")
greeting_text = f"Greetings, human. I am {robot_name}. How may I assist you today?"
os.makedirs('output', exist_ok=True)
output_directory = 'output/audio'
os.makedirs(output_directory, exist_ok=True)
tts = gTTS(text=greeting_text, lang='en')
tts.save('output/greeting.mp3')
os.system("start output/greeting.mp3")

tts.save(os.path.join(output_directory, "greeting.mp3"))
time.sleep(1)
audio_path = ("output/audio/greeting.mp3")
play_audio(audio_path)

def main():
greet_user()

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ pyaudio==0.2.14
pydub==0.25.1
beautifulsoup4==4.10.0
SpeechRecognition==3.10.1
pygame==2.5.2
openai==0.28
13 changes: 13 additions & 0 deletions scripts/play_audio.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pygame
import time

def play_audio(audio_path):
pygame.mixer.init()
pygame.mixer.music.load(audio_path)

play_count = 0
while play_count < 1:
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
time.sleep(1)
play_count += 1

0 comments on commit 2cd8b63

Please sign in to comment.