Update Uptated-Prototype/TTS-Script-PiperTTS 2nd.py
This commit is contained in:
@@ -5,6 +5,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
from piper.voice import SynthesisConfig
|
from piper.voice import SynthesisConfig
|
||||||
|
import atexit
|
||||||
|
|
||||||
result = subprocess.run(["xsel"], capture_output=True, text=True) # In Theory grab selected text into Varible called TextToSpeak
|
result = subprocess.run(["xsel"], capture_output=True, text=True) # In Theory grab selected text into Varible called TextToSpeak
|
||||||
#print(result) # In Theory grab selected text and print ot to terminal
|
#print(result) # In Theory grab selected text and print ot to terminal
|
||||||
@@ -33,10 +34,8 @@ first_chunk = next(chunks) # Get the first chunk to set up audio stream configur
|
|||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
count = 1
|
result = len(list(chunks))
|
||||||
for chunk in chunks: # Play subsequent chunks of audio
|
print(result) # Print the amount of chunks
|
||||||
count += 1
|
|
||||||
print(count) # Print the amount of chunks
|
|
||||||
except:
|
except:
|
||||||
print("Failed getting Chunk Count")
|
print("Failed getting Chunk Count")
|
||||||
try:
|
try:
|
||||||
@@ -57,7 +56,13 @@ stream.write(first_chunk.audio_int16_bytes) # Play the first chunk
|
|||||||
for chunk in chunks: # Play subsequent chunks of audio
|
for chunk in chunks: # Play subsequent chunks of audio
|
||||||
stream.write(chunk.audio_int16_bytes)
|
stream.write(chunk.audio_int16_bytes)
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
stream.stop_stream()
|
# Function called on Exit
|
||||||
stream.close()
|
def Registered_Exit():
|
||||||
p.terminate()
|
# Cleanup
|
||||||
|
stream.stop_stream()
|
||||||
|
stream.close()
|
||||||
|
p.terminate()
|
||||||
|
|
||||||
|
# Regestering Exit
|
||||||
|
atexit.register(Registered_Exit)
|
||||||
Reference in New Issue
Block a user