From de15cdd809985eebbadbf237ec48f610629e3d6b Mon Sep 17 00:00:00 2001 From: Don Flymoor <36929174+DonFlymoor@users.noreply.github.com> Date: Thu, 24 Sep 2020 08:51:35 -0400 Subject: [PATCH] Squashed 3 bugs --- changelog.txt | 5 ++++- setup.py | 2 +- voxtalkz/__init__.py | 2 +- voxtalkz/voxtalkz.py | 34 +++++++++++++++++++++------------- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/changelog.txt b/changelog.txt index 031b07d..d715c40 100644 --- a/changelog.txt +++ b/changelog.txt @@ -35,4 +35,7 @@ version 1.2.4 - And more bugs 1.2.5 -- Added ssml input with readable usage \ No newline at end of file +- Added ssml input with readable usage +1.2.6 +- Better readability for scripts +- Sqaushed 3 bugs \ No newline at end of file diff --git a/setup.py b/setup.py index f034249..ba40d2b 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ EMAIL = 'donflymoor@gmail.com' AUTHOR = 'Don Flymoor' REQUIRES_PYTHON = '>=3.6.0' -VERSION = '1.2.5' +VERSION = '1.2.6' # What packages are required for this module to be executed? REQUIRED = [ diff --git a/voxtalkz/__init__.py b/voxtalkz/__init__.py index 269b0fc..3af0161 100644 --- a/voxtalkz/__init__.py +++ b/voxtalkz/__init__.py @@ -4,4 +4,4 @@ from .voxtalkz import * -__version__ = '1.2.5' +__version__ = '1.2.6' diff --git a/voxtalkz/voxtalkz.py b/voxtalkz/voxtalkz.py index b1f2917..8b89e31 100644 --- a/voxtalkz/voxtalkz.py +++ b/voxtalkz/voxtalkz.py @@ -14,6 +14,7 @@ import json import os import base64 +import errno File = 'null' @@ -274,23 +275,30 @@ def ListToSound(self, Lists): if "@" in List[1]: effects=(List[1].split('@'))[1] List[1]=(List[1].split('@'))[0] + List[1] = List[1].replace('*', '') # Check to see if it's a sound effect if List[0] == 'SOUND': if self.debug: print('Makeing %s...'%List[1]) while True: try: - try: - audio_segment = AudioSegment.from_mp3(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.mp3') - except: - audio_segment = AudioSegment.from_wav(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.wav') - finally: - audio_segment = AudioSegment.from_ogg(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.ogg') + fileName = List[1] + filePath = self.homedir+'\\.voxTalkz\\soundEffects\\'+ fileName + if os.path.exists(filePath+'.mp3'): + audio_segment = AudioSegment.from_mp3(filePath+'.mp3') + elif os.path.exists(filePath+'.wav'): + audio_segment = AudioSegment.from_wav(filePath+'.wav') + elif os.path.exists(filePath+'.ogg'): + audio_segment = AudioSegment.from_ogg(filePath+'.ogg') + else: + raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filePath) + if self.debug: print("Done!\n") break - except: - contd = input('\n !!! Could not open %s'%(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.mp3 (or .wav, or ogg) !!! Type continue to skip the sound effect, retry to retry after you\'ve fixed the problem, or exit to quit.')) + except Exception as e: + print(e) + contd = input('Type continue to skip the sound effect, retry to retry after you\'ve fixed the problem, or exit to quit.') if contd == 'continue': break elif contd == 'retry': @@ -349,7 +357,6 @@ def ListToSound(self, Lists): text_type = "text" data = { - "speakingRate":1, "input": {text_type: text}, "voice": {"name": self.Actors[List[0]][0], "languageCode": self.Actors[List[0]][1]}, "audioConfig": {"audioEncoding": "MP3"} @@ -371,6 +378,7 @@ def ListToSound(self, Lists): except Exception as Error: print('Error while using wavenet voice!') print(Error) + print(content) if self.debug: print('Done!\n') @@ -473,7 +481,7 @@ def to_ssml(self, text): There are many other ssml notaions, all of which are supported, but will have to be manually entered ''' - text = ' ' + text + '' + text = ' ' + text + ' ' replace_dict = {' __' : ' ', '__ ' : ' ', ' _' : ' ', @@ -489,7 +497,7 @@ def to_ssml(self, text): '..' : ''} for string in replace_dict: - text.replace(string, replace_dict[string]) + text = text.replace(string, replace_dict[string]) return text def save(self): @@ -526,8 +534,8 @@ def say(*args, **kwargs): print('Usage: --cloud [text-to-speach API key]') args.remove("--cloud") - elif len(args) != 3: - print("Expecting two arguments! Usage: voxtalkz [input file, output file] ") + # elif len(args) != 3: + # print("Expecting two arguments! Usage: voxtalkz [input file, output file] ") else: print(args)