Skip to content

Commit

Permalink
MSTranslator Enhancement
Browse files Browse the repository at this point in the history
- Renamed functions to MSTranslator instead of MSSpeak
- Modified settings files to use client_id and client_secret
  • Loading branch information
joshpatten committed Oct 9, 2015
1 parent cf2f0c8 commit 6fc6258
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 43 deletions.
23 changes: 6 additions & 17 deletions lua/libs/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,25 @@ DBPASS = 'password'
DBPORT = 5432

--
-- Select the TTS engine, value : flite, acapela, msspeak
-- Select the TTS engine, value : flite, acapela, mstranslator
--
TTS_ENGINE = 'flite'

--
-- Acapela and MSSpeak TTS Settings
-- MSSpeak only needs APPLICATION_LOGIN(client_id)
-- and APPLICATION_PASSWORD(client_secret).
-- ACCOUNT_LOGIN is ignored for MSSpeak
-- Acapela TTS Settings
--
ACCOUNT_LOGIN = 'EVAL_VAAS'
APPLICATION_LOGIN = 'EVAL_YYYYYYY'
APPLICATION_PASSWORD = 'XXXXXXXX'

--
-- For MSSpeak comment out Acapela SERVICE_URL
-- and uncomment other SERVICE_URL parameter
--
-- SERVICE_URL = 'http://api.microsofttranslator.com/V2/Http.svc/Speak'
SERVICE_URL = 'http://vaas.acapela-group.com/Services/Synthesizer'

--
-- Acapela Specific Settings
--
QUALITY = '22k' -- 22k, 8k, 8ka, 8kmu
ACAPELA_GENDER = 'W'
ACAPELA_INTONATION = 'NORMAL'
ACAPELA_LANG = 'EN'

--
-- Microsoft Speak Specific Settings
-- Microsoft Translator TTS Settings
--
MSSPEAK_LANGUAGE = 'EN'
CLIENT_ID = 'XXXXXXXXXXXX'
CLIENT_SECRET = 'YYYYYYYYYYYYYY'
MSTRANSLATOR_LANG = 'EN'
19 changes: 9 additions & 10 deletions lua/libs/texttospeech.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,16 @@ function tts(text, tts_dir)
output_file = tts_acapela:run()
end

elseif TTS_ENGINE == 'msspeak' then
-- Microsoft Speak
MSSpeak = require "msspeak"
tts_msspeak = MSSpeak:new{
APPLICATION_LOGIN=APPLICATION_LOGIN,
APPLICATION_PASSWORD=APPLICATION_PASSWORD,
SERVICE_URL=SERVICE_URL,
elseif TTS_ENGINE == 'mstranslator' then
-- Microsoft Translator
MSTranslator = require "mstranslator"
tts_mstranslator = MSTranslator:new{
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
DIRECTORY=tts_dir}
tts_msspeak:set_cache(true)
tts_msspeak:prepare(text, MSSPEAK_LANG)
output_file = tts_msspeak:run()
tts_mstranslator:set_cache(true)
tts_mstranslator:prepare(text, MSTRANSLATOR_LANG)
output_file = tts_mstranslator:run()
end
return output_file
end
15 changes: 6 additions & 9 deletions newfies/newfies_dialer/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,24 +534,21 @@

# TEXT-TO-SPEECH
# ==============
TTS_ENGINE = 'FLITE' # FLITE, CEPSTRAL, ACAPELA, MSSPEAK
TTS_ENGINE = 'FLITE' # FLITE, CEPSTRAL, ACAPELA, MSTRANSLATOR

# ACAPELA AND MSSPEAK SETTINGS
# MSSPEAK only needs APPLICATION_LOGIN(client_id)
# and APPLICATION_PASSWORD(client_secret).
# ACCOUNT_LOGIN is ignored for MSSpeak
# ACAPELA SPECIFIC SETTINGS
ACCOUNT_LOGIN = 'EVAL_XXXX'
APPLICATION_LOGIN = 'EVAL_XXXXXXX'
APPLICATION_PASSWORD = 'XXXXXXXX'

# Service URL for Acapela
SERVICE_URL = 'http://vaas.acapela-group.com/Services/Synthesizer'

# ACAPELA SPECIFIC SETTINGS
QUALITY = '22k' # 22k, 8k, 8ka, 8kmu
ACAPELA_GENDER = 'W'
ACAPELA_INTONATION = 'NORMAL'

# MSTRANSLATOR SPECIFIC SETTINGS
CLIENT_ID = 'XXXXXXXXXXXX'
CLIENT_SECRET = 'YYYYYYYYYYYYYY'

# DEBUG DIALER
# ============
DIALERDEBUG = False
Expand Down
6 changes: 3 additions & 3 deletions newfies/survey/function_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
from django.conf import settings

def getaudio_msspeak(text, tts_language='en'):
def getaudio_mstranslator(text, tts_language='en'):
"""
Run Microsoft Speak Text2Speech and return audio url
"""
Expand All @@ -22,8 +22,8 @@ def getaudio_msspeak(text, tts_language='en'):
if not tts_language:
tts_language = 'en'
tts_msspeak = msspeak.MSSpeak(
settings.APPLICATION_LOGIN,
settings.APPLICATION_PASSWORD,
settings.CLIENT_ID,
settings.CLIENT_SECRET,
DIRECTORY)
output_filename = tts_msspeak.speak(
text, tts_language)
Expand Down
8 changes: 4 additions & 4 deletions newfies/survey/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
SEALED_SURVEY_COLUMN_NAME
from survey.models import post_save_add_script
from survey.function_def import getaudio_acapela
from survey.function_def import getaudio_msspeak
from survey.function_def import getaudio_mstranslator
from django_lets_go.common_functions import striplist, ceil_strdate, getvar, unset_session_var,\
get_pagination_vars
from mod_utils.helper import Export_choice
Expand Down Expand Up @@ -517,9 +517,9 @@ def section_script_play(request, id):
if settings.TTS_ENGINE == 'ACAPELA':
# Acapela
audio_file_path = settings.MEDIA_ROOT + '/' + getaudio_acapela(script_text, 'US')
elif settings.TTS_ENGINE == 'MSSPEAK':
# Microsoft Speak
audio_file_path = settings.MEDIA_ROOT + '/' + getaudio_msspeak(script_text, 'en')
elif settings.TTS_ENGINE == 'MSTRANSLATOR':
# Microsoft Translator
audio_file_path = settings.MEDIA_ROOT + '/' + getaudio_mstranslator(script_text, 'en')
else:
# Flite
script_hexdigest = hashlib.md5(script_text).hexdigest()
Expand Down

0 comments on commit 6fc6258

Please sign in to comment.