Skip to content

Commit

Permalink
refactor: Update file paths for chatlogs and uploads directories
Browse files Browse the repository at this point in the history
fix: emoji speak ignoring
  • Loading branch information
MrSco committed Aug 1, 2024
1 parent 94a01e8 commit a8fef58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def is_running_on_raspberry_pi():
assistant_name = assistant["name"]
assistant_acronym = assistant["acronym"]
today = str(date.today())
chatlog_filename = os.path.join("chatlogs", f"{config['assistant']}_chatlog-{today}.txt")
chatlog_filename = os.path.join(script_dir, "chatlogs", f"{config['assistant']}_chatlog-{today}.txt")
if not os.path.exists("chatlogs"):
os.makedirs("chatlogs")

Expand Down Expand Up @@ -422,7 +422,7 @@ def handle_file_chunk(data):
print(f"Received all chunks for file {file_id}.")
if not use_imgur:
file_data = b"".join(file_chunks[file_id])
upload_path = config['upload_folder']
upload_path = os.path.join(script_dir, config['upload_folder'])
if not os.path.exists(upload_path):
os.makedirs(upload_path)

Expand Down
7 changes: 6 additions & 1 deletion tts_service.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import time
from elevenlabs import VoiceSettings
from elevenlabs import stream
Expand All @@ -23,11 +24,15 @@ def __init__(self, config):
self.start_time = None
self.end_time = None

def remove_non_ascii(self, text):
return re.sub(r'[^\x00-\x7F]+', '', text)

def speak(self, text):
textToSpeak = text
self.start_time = time.time()
try:
# strip out emojis so we don't try to speak them
textToSpeak = text.encode('ascii', 'ignore').decode('ascii')
textToSpeak = self.remove_non_ascii(text)
if not self.use_elevenlabs:
if self.use_gtts:
self.speak_with_gtts(textToSpeak)
Expand Down

0 comments on commit a8fef58

Please sign in to comment.