Package: enderturing
Ender TuringEnder Turing is a solution for voice content understanding, analytics and business insights.
Checkenderturing.comfor details.Installation$pipinstallenderturingFor using streaming speech recognition functions, you'll also need FFmpeg installed.Ubuntu:$sudoaptinstallffmpegMacOS homebrew:$brewinstallffmpegFor other OS, please follow FFmpeg installation guides.Quick StartimportasynciofromenderturingimportConfig,EnderTuring,RecognitionResultFormat# create configurationconfig=Config.from_url("https://admin%40local.enderturing.com:your_password@enterturing.yourcompany.com")et=EnderTuring(config)# access sessions listsessions=et.sessions.list()print(sessions)# get recognizer for one of configured languagesrecognizer=et.get_speech_recognizer(language='en')asyncdefrun_stream_recog(f,r,result_format):asyncwithr.stream_recognize(f,result_format=result_format)asrec:text=awaitrec.read()returntext# recognize specified fileloop=asyncio.get_event_loop()task=loop.create_task(run_stream_recog("my_audio.mp3",recognizer,result_format=RecognitionResultFormat.text))loop.run_until_complete(task)print(task.result())UsageSDK contains two major parts:Using Ender Turing REST APISpeech recognitionUsing Ender Turing APIAll API calls are accessible via an instance orEnderTuring. API methods are grouped, and each
group is a property ofEnderTuring. Examples:fromenderturingimportConfig,EnderTuring,RecognitionResultFormatet=EnderTuring(Config.from_env())# access sessions listsessions=et.sessions.list()# working with ASRet.asr.get_instances(active_only=True)# accessing raw jsonet.raw.create_event(caller_id='1234',event_data={"type":"hold"})Access ConfigurationTo access API, you need to know an authentication key (login), authentication secret (password), and
installation URL (e.g.https://enderturing.yourcompany.com/)There are multiple ways to pass config options:from environmental variables (Config.from_env()).creatingConfigwith parameters (e.g.Config(auth_key="my_login", auth_secret="my_secret""))using Enter Turing configuration URL (Config.from_url())Creating Speech RecognizerThere two options to create a speech recognizer:If you have access to API configured:recognizer=et.get_speech_recognizer(language='en')If you know URL and sample rate of desired ASR instance:fromenderturingimportAsrConfig,SpeechRecognizerconfig=AsrConfig(url="wss://enderturing",sample_rate=8000)recognizer=SpeechRecognizer(config)Recognizing a FileSpeechRecognizer.recognize_filemethod returns an async text stream. Depending on parameters,
each line contains either a text of utterance or serialized JSON.If you are only interested in results after recognition is complete, you can use theread()method. E.g.asyncwithrecognizer.recognize_file("my_audio.wav",result_format=RecognitionResultFormat.text)asrec:text=awaitrec.read()If you prefer getting words and phrases as soon as they are recognized - you can
use thereadline()method instead. E.g.asyncwithrecognizer.recognize_file(src,result_format=RecognitionResultFormat.jsonl)asrec:line=awaitrec.readline()whileline:# Now line contains a json string, you can save it or do something else with itline=awaitrec.readline()Working With Multichannel AudioIf an audio file has more than one channel - by default system will recognize each channel and
return a transcript for each channel. To change the default behavior - you can usechannelsparameter ofSpeechRecognizer.recognize_file. Please check method documentation for details.Sometimes an audio is stored as a file per channel, e.g., contact center call generates two files:
one for a client and one for a support agent. But for analysis, it's preferable to see transcripts
of the files merged as a dialog. In this scenario, you can userecognizer.recognize_joined_file([audio1, audio2]).LicenseReleased under the MIT license.