Update Uptated-Prototype/TTS-Script-PiperTTS 2nd.py
This commit is contained in:
@@ -5,6 +5,7 @@ import os
|
||||
import subprocess
|
||||
import time
|
||||
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
|
||||
#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:
|
||||
count = 1
|
||||
for chunk in chunks: # Play subsequent chunks of audio
|
||||
count += 1
|
||||
print(count) # Print the amount of chunks
|
||||
result = len(list(chunks))
|
||||
print(result) # Print the amount of chunks
|
||||
except:
|
||||
print("Failed getting Chunk Count")
|
||||
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
|
||||
stream.write(chunk.audio_int16_bytes)
|
||||
|
||||
|
||||
# Function called on Exit
|
||||
def Registered_Exit():
|
||||
# Cleanup
|
||||
stream.stop_stream()
|
||||
stream.close()
|
||||
p.terminate()
|
||||
|
||||
# Regestering Exit
|
||||
atexit.register(Registered_Exit)
|
||||
Reference in New Issue
Block a user