Use NLP instead of Regex to get each sentence

This commit is contained in:
rany
2021-05-11 00:38:46 +03:00
parent c3be6ef493
commit aa902aba30

View File

@@ -5,6 +5,7 @@ import uuid
import argparse import argparse
import urllib.request import urllib.request
import websocket # pip install websocket-client import websocket # pip install websocket-client
from nltk.tokenize import wordpunct_tokenize
from xml.sax.saxutils import quoteattr as escape from xml.sax.saxutils import quoteattr as escape
try: try:
import thread import thread
@@ -81,7 +82,7 @@ if __name__ == "__main__":
volumeString = args.volume volumeString = args.volume
sentenceBoundaryEnabled = 'True' if args.enable_sentence_boundary else 'False' sentenceBoundaryEnabled = 'True' if args.enable_sentence_boundary else 'False'
wordBoundaryEnabled = 'True' if args.disable_word_boundary else 'False' wordBoundaryEnabled = 'True' if args.disable_word_boundary else 'False'
text = args.text.replace(chr(9), " ").replace(chr(13), " ").replace(chr(32), " ") for text in wordpunct_tokenize(args.text.replace(chr(9), " ").replace(chr(13), " ").replace(chr(32), " ")):
run_tts() run_tts()
elif args.list_voices is True: elif args.list_voices is True:
list_voices() list_voices()