Skip to content

Commit

Permalink
Merge pull request elebumm#535 from JasonLovesDoggo/master
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
JasonLovesDoggo authored Jun 17, 2022
2 parents 83848b7 + 27b260f commit fa50879
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions TTS/POLLY.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import sox
from moviepy.audio.AudioClip import concatenate_audioclips, CompositeAudioClip
from moviepy.audio.io.AudioFileClip import AudioFileClip
from requests.exceptions import JSONDecodeError

voices = ['Brian', 'Emma', 'Russell', 'Joey', 'Matthew', 'Joanna', 'Kimberly', 'Amy', 'Geraint', 'Nicole', 'Justin', 'Ivy', 'Kendra', 'Salli', 'Raveena']


Expand Down Expand Up @@ -35,10 +37,10 @@ def tts(
voice_data = requests.get(response.json()['speak_url'])
with open(filename, 'wb') as f:
f.write(voice_data.content)
except KeyError:
except (KeyError, JSONDecodeError):
if response.json()['error'] == 'Text length is too long!':
chunks = [
m.group().strip() for m in re.finditer(r" *((.{0,530})(\.|.$))", req_text)
m.group().strip() for m in re.finditer(r" *((.{0,499})(\.|.$))", req_text)
]

audio_clips = []
Expand Down

0 comments on commit fa50879

Please sign in to comment.