Skip to content

Commit

Permalink
Fixed cache arrangement and all my other errors
Browse files Browse the repository at this point in the history
Former-commit-id: 285a9cf
  • Loading branch information
eternalliving committed Mar 20, 2022
1 parent 0aa6b55 commit 7f22a9c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def glados_tts(text, key=False):

from flask import Flask, request, send_file
import urllib.parse
import shutil

print("\033[1;94mINFO:\033[;97m Initializing TTS Server...")

Expand All @@ -95,21 +96,23 @@ def synthesize(text):

# Update access time. This will allow for routine cleanups
os.utime(file, None)

print("\033[1;94mINFO:\033[;97m The audio sample sent from cache.")
return send_file(file)

# Generate New Sample
key = str(time.time())[7:]
if(glados_tts(line, key)):
tempfile = os.getcwd()+'/audio/GLaDOS-tts-temp-output-'+key+'.wav'
return send_file(tempfile)


# If the line isn't too long, store in cache
if(len(line) < 200 and CACHE):
shutil.move(tempfile, filename)
shutil.move(tempfile, file)
else:
return send_file(tempfile)
os.remove(tempfile)

return send_file(file)

else:
return 'TTS Engine Failed'

Expand Down

0 comments on commit 7f22a9c

Please sign in to comment.