Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

festival_plugin: add support for different encodings #249

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sound_play/src/sound_play/festival_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def __init__(self):
def sound_play_say_plugin(self, text, voice):
if voice is None or voice == '':
voice = self._default_voice
encoding = 'ISO-8859-15'
if ':' in voice:
voice, encoding = voice.split(':', maxsplit=1)
txtfile = tempfile.NamedTemporaryFile(
prefix='sound_play', suffix='.txt')
(wavfile, wavfilename) = tempfile.mkstemp(
Expand All @@ -26,10 +29,10 @@ def sound_play_say_plugin(self, text, voice):
try:
if hasattr(text, 'decode'):
txtfile.write(
text.decode('UTF-8').encode('ISO-8859-15'))
text.decode('UTF-8').encode(encoding))
else:
txtfile.write(
text.encode('ISO-8859-15'))
text.encode(encoding))
except UnicodeEncodeError:
if hasattr(text, 'decode'):
txtfile.write(text)
Expand Down
Loading