예제 #1
0
    def make_request(creds=None,
                     desired_tts_lang=None,
                     text=None,
                     filename=None,
                     sample_rate=16000,
                     nchannels=1,
                     sample_width=2,
                     audio_type='wav'):

        if text is None:
            return None

        tts_req = TTSRequest(desired_tts_lang, credentials=creds)
        tts_req.sample_rate = sample_rate
        tts_req.nchannels = nchannels
        tts_req.sample_width = sample_width
        tts_req.audioType = audio_type

        if desired_tts_lang is not None:
            tts_req.voice = desired_tts_lang['properties']['voice']

        tts_req.synthesize_to_file(filename, text)  # unicode text

        if tts_req.response.was_successful():
            print green("✓ TTS", bold=True)
        else:
            print red("× TTS", bold=True)

        return tts_req
예제 #2
0
    def make_request(creds=None,
                     desired_asr_lang=None,
                     filename=None,
                     mode='quiet',
                     requestor_id=None):

        aReq = ChunkedASRRequest(desired_asr_lang,
                                 credentials=creds,
                                 requestor_id=requestor_id)
        aReq.load_file(filename)

        analyze_function = None
        if aReq.audio_type == 'wav':
            analyze_function = ASR.__read_wav_file_in_chunks
        elif aReq.audio_type == 'speex':
            analyze_function = ASR.__read_file_in_chunks

        if analyze_function is None:
            print "Don't know how to stream this file... %s" % filename
            sys.exit(-1)

        if mode == 'verbose':
            result = aReq.analyze(analyze_function, mode)
        else:
            result = aReq.analyze(analyze_function)

        if result.was_successful():
            print green("✓ ASR", bold=True)
        else:
            print red("× ASR", bold=True)

        return aReq
예제 #3
0
    def make_request(
        creds=None,
        desired_tts_lang=None,
        text=None,
        filename=None,
        sample_rate=16000,
        nchannels=1,
        sample_width=2,
        audio_type="wav",
    ):

        if text is None:
            return None

        tts_req = TTSRequest(desired_tts_lang, credentials=creds)
        tts_req.sample_rate = sample_rate
        tts_req.nchannels = nchannels
        tts_req.sample_width = sample_width
        tts_req.audioType = audio_type

        if desired_tts_lang is not None:
            tts_req.voice = desired_tts_lang["properties"]["voice"]

        tts_req.synthesize_to_file(filename, text)  # unicode text

        if tts_req.response.was_successful():
            print green("✓ TTS", bold=True)
        else:
            print red("× TTS", bold=True)

        return tts_req
예제 #4
0
	def make_request(creds=None, desired_asr_lang=None, filename=None, mode='quiet', requestor_id=None):

		aReq = ChunkedASRRequest(desired_asr_lang, credentials=creds, requestor_id=requestor_id)
		aReq.load_file(filename)
		
		analyze_function = None
		if aReq.audio_type == 'wav':
			analyze_function = ASR.__read_wav_file_in_chunks
		elif aReq.audio_type == 'speex':
			analyze_function = ASR.__read_file_in_chunks
		
		if analyze_function is None:
			print "Don't know how to stream this file... %s" % filename
			sys.exit(-1)
			
		if mode == 'verbose':
			result = aReq.analyze(analyze_function, mode)
		else:
			result = aReq.analyze(analyze_function)

		if result.was_successful():
			print green("✓ ASR",bold=True)
		else:
			print red("× ASR",bold=True)

		return aReq