-
-
Save deepanshu-nickelfox/10c35030ff9c9b64658d5aa57d1fdaa6 to your computer and use it in GitHub Desktop.
Revisions
-
harunurkst renamed this gist
May 8, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
harunurkst created this gist
May 8, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ def djangoview(request, language1, language2): async def main(language1, language2): loop = asyncio.get_event_loop() r = sr.Recognizer() with sr.AudioFile(path.join(os.getcwd(), "audio.wav")) as source: audio = r.record(source) def reco_ibm(lang): return(r.recognize_ibm(audio, key, secret language=lang, show_all=True)) future1 = loop.run_in_executor(None, reco_ibm, str(language1)) future2 = loop.run_in_executor(None, reco_ibm, str(language2)) response1 = await future1 response2 = await future2 loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop = asyncio.get_event_loop() loop.run_until_complete(main(language1, language2)) loop.close() return(HttpResponse)