fix stuff

This commit is contained in:
2026-09-21 01:55:42 -04:00
commit 02d7c10f7d
26 changed files with 953 additions and 0 deletions

0
audio/__init__.py Normal file
View File

8
audio/audio_queue.py Normal file
View File

@@ -0,0 +1,8 @@
import queue
q = queue.Queue()
def callback(indata, frames, time_, status):
if status:
print(status)
q.put(bytes(indata))

15
audio/chime.py Normal file
View File

@@ -0,0 +1,15 @@
import time
import pygame
from config import CHIME_FILE
def play_ding():
pygame.mixer.init()
pygame.mixer.music.load(CHIME_FILE)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
time.sleep(0.05)
pygame.mixer.music.unload()
pygame.mixer.quit()

20
audio/gtts.py Normal file
View File

@@ -0,0 +1,20 @@
import os
import tempfile
import time
import pygame
from gtts import gTTS
def speak(text):
with tempfile.TemporaryDirectory() as tmpdirname:
temp_path = os.path.join(tmpdirname, "speech.mp3")
tts = gTTS(text=text,lang='en', tld='com')
tts.save(temp_path)
pygame.mixer.init()
pygame.mixer.music.load(temp_path)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
time.sleep(0.1)
pygame.mixer.music.unload()
pygame.mixer.quit()

33
audio/tts.py Normal file
View File

@@ -0,0 +1,33 @@
import asyncio
import os
import tempfile
import time
import edge_tts
import pygame
def speak(text):
async def generate_speech():
voice = "en-US-ChristopherNeural"
communicate = edge_tts.Communicate(text, voice)
await communicate.save(temp_path)
with tempfile.TemporaryDirectory() as tmpdirname:
temp_path = os.path.join(tmpdirname, "speech.mp3")
asyncio.run(generate_speech())
pygame.mixer.init()
pygame.mixer.music.load(temp_path)
pygame.mixer.music.play()
while pygame.mixer.music.get_busy():
time.sleep(0.1)
pygame.mixer.music.unload()
pygame.mixer.quit()
if __name__ == "__main__":
speak("Hello! I am now speaking using Microsoft Edge's natural text to speech engine.")