Example #1
0
def Index():
    global CHAT_TEMPLATE, STT_USERNAME, STT_PASSWORD, TTS_USERNAME, TTS_PASSWORD
    if SECURITY == 'ON' and g('AUTHENTICATED', 0) != True:
        return redirect(url_for('.Login'))


#	Initialize SST & TTS tokens
    stt_token = Authorization(
        username=STT_USERNAME,
        password=STT_PASSWORD).get_token(url=SpeechToText.default_url)
    tts_token = Authorization(
        username=TTS_USERNAME,
        password=TTS_PASSWORD).get_token(url=TextToSpeech.default_url)
    s('STT_TOKEN', stt_token)
    s('TTS_TOKEN', tts_token)
    #	Initialize chat
    s('POSTS', [])
    response = ''
    response_json = BMIX_get_first_dialog_response_json()
    if response_json != None:
        s('DIALOG_CLIENT_ID', response_json['client_id'])
        s('DIALOG_CONVERSATION_ID', response_json['conversation_id'])
        response = response_json['response']
    post_watson_response(response)
    return render_template(CHAT_TEMPLATE,
                           posts=g('POSTS', []),
                           form='',
                           stt_token=stt_token,
                           tts_token=tts_token)
Example #2
0
def getTtsToken():
    if (TTS_APIKEY):
        iamTokenManager = IAMTokenManager(iam_apikey=TTS_APIKEY)
        token = iamTokenManager.get_token()
    else:
        authorization = Authorization(username=TTS_USERNAME,
                                      password=TTS_PASSWORD)
        token = authorization.get_token(url=TTS_URL)
    return token
def getSttToken():
    try:
        data = request.form.get('data')
        authorization = Authorization(username=speachtotextUser,
                                      password=speachtotextPassword)
        retvalue = authorization.get_token(url=SpeechToText.default_url)
    except Exception as e:
        print(e)
    return retvalue
def getTtsToken():
    try:
        data = request.form.get('data')
        authorization = Authorization(username=texttospeachUser,
                                      password=texttospeachPassword)
        retvalue = authorization.get_token(url=TextToSpeech.default_url)
    except Exception as e:
        print(e)
    return retvalue
Example #5
0
def get_token(request):
    """
    Request watson service to get token for streaming service
    """
    username = os.environ.get('username')
    password = os.environ.get('password')

    authorization = Authorization(username=username, password=password)

    return HttpResponse(authorization.get_token(url=SpeechToText.default_url),
                        content_type='text/plain')
Example #6
0
def getSttToken():
    authorization = Authorization(
        username='******',
        password='******')
    return authorization.get_token(url=SpeechToText.default_url)
def getTtsToken():
	authorization = Authorization(username=TTS_USERNAME, password=TTS_PASSWORD)
	return authorization.get_token(url=TextToSpeech.default_url)
def getSttToken():
	print(STT_USERNAME)
	authorization = Authorization(username=STT_USERNAME, password=STT_PASSWORD)
	return authorization.get_token(url=SpeechToText.default_url)
def get_tts_token():
    global TTS_USERNAME, TTS_PASSWORD
    return Authorization(
        username=TTS_USERNAME,
        password=TTS_PASSWORD).get_token(url=TextToSpeech.default_url)
def get_stt_token():
    global STT_USERNAME, STT_PASSWORD
    return Authorization(
        username=STT_USERNAME,
        password=STT_PASSWORD).get_token(url=SpeechToText.default_url)
Example #11
0
import json
from watson_developer_cloud import AuthorizationV1 as Authorization
from watson_developer_cloud import SpeechToTextV1 as SpeechToText

authorization = Authorization(username='******',
                              password='******')

print(json.dumps(authorization.get_token(url=SpeechToText.default_url), indent=2))
Example #12
0
 def obtain_auth_token(self):
     STT_USERNAME = os.environ['STT_USERNAME'] # '<Speech to Text username>'
     STT_PASSWORD = os.environ['STT_PASSWORD'] # '<Speech to Text password>'
     authorization = Authorization(username=STT_USERNAME, password=STT_PASSWORD)
     return authorization.get_token(url=SpeechToText.default_url)