From 26318959cc52ea953785ca3d290ba63b75d1c050 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 3 Mar 2018 01:13:07 +0100 Subject: [PATCH 1/4] made changes to ttstt at makefile --- Makefile | 3 +- ocr/list.txt | 4 + ocr/output.txt | 199 +++++++++++++++++++++++++++++++++++++++++++++ src/soundtotext.py | 2 + 4 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 ocr/list.txt create mode 100644 ocr/output.txt create mode 100644 src/soundtotext.py diff --git a/Makefile b/Makefile index 17be5f9..c062555 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ clean: ## removes output (target) files dirs: ## create the dirs in working dir @-mkdir -p images/ @-mkdir -p output/ + @-mkdir -p ocr/ @echo $(color_r)'Directories made': images/ output/ @@ -86,6 +87,6 @@ tts: output/chatbot.txt ocr/output.txt ## text to speech. Dependencies: espea cat $? | espeak ttstt: ocr/output.txt##text to speech, speech to text - cat $< | espeak -s 140 -v f2 --stdout > sound.wav + cat $< | espeak -s 140 -v f2 --stdout > output/sound.wav diff --git a/ocr/list.txt b/ocr/list.txt new file mode 100644 index 0000000..887fc17 --- /dev/null +++ b/ocr/list.txt @@ -0,0 +1,4 @@ + +images/0004.jpg +images/0006.jpg + diff --git a/ocr/output.txt b/ocr/output.txt new file mode 100644 index 0000000..3b35384 --- /dev/null +++ b/ocr/output.txt @@ -0,0 +1,199 @@ + + + + +[J MASTHEAD +int-F urniu . : .“l’ll' 'J + +Masthead + +Editorial Team +Ana (liruilhu +gmger twins + +Ritardo Lat-Liente + +Copy editor + +Margaret Burnett + +Pubfisher + +ginger (001’!g + +Community Board +Dave Crossland + +Louis Desmrdms + +AVTTIt'TlL Hansoux + +Alexandre Prokoudine + +Femke Snelting + +Contributors +Daxe Crossland. Maria Figueiredo, Nelson Concalves. Eric de + +Haas Richard Hugheslonathan Puckey, Eric behriiver + +Printed in Port. by Crornotema (http: troinotemapt) and in +T: into M Green Printer (http’ v.wwgreenprinteronlinc-.4 om‘l + +in rerwled paper + +Lli ensed under at redinek ummons Attril-u’iioi‘i-Rhare Alike +lli r‘l'lv: N l rmrsm '\|l . (Intent \hlluld be attributed to II\ +iridiuidiial lUlhIlT all . ante-m \titl‘i-iut :1 stated author 4 (iii lm + +'TE‘dlir-diiiLilitf‘lrir.1[il]ii\ Hagar”):- + +Contacts + +»\ Hi" to u .1! Hlllllllilv“.iiI‘lll11{"L“i.jplili trying i an: + +HTTP: LIBRFl iRAl’Hll 'beU i.( HM + +Images under a ( (' Attribution Sharr- Aliki- “1 Nine + +l’lmii- mi piii‘gvi Vll‘l’)‘, lit, lii-i- all + +I'll ill. u-l Iv’u ii-lu l .illll‘lil“ liv. "\im‘ .ir'..illi“lllliv li-llll‘ ’i "il'|' .Iiililll<.llllil‘dllillilllt‘illl‘llH‘ili‘JluIi‘ iiu-iiliniiiul + +ilu'iu-m ".li ~lli ll‘l'll’l'll'l l‘vi Milt Ilii l'ul'lillilll ml llIV'.|Vl lilgliliinni lll lll" .llllv ll‘ + +lei.‘ ,t‘miiln. .l‘li‘ it il l 'lliltlllI‘ R‘.lll\ ll yr lli rim .1 lllltll‘l (i H» +lllii‘,li,illlili'. iii Jul-la Illil“".lll-lll,i1llil 5pm. .m lllll'l\ll .\ .'.llll loin | l'r lmri +li, l'llll l l i lllll'l +l'li I- ill ' “l'4ll||l)_ lilliii ' llii l l"|i|-ii‘llilli \.ilil-I.iliiiii \‘rlil lix l-'ii ll-Illl lllll‘lllv“. + +Lin, lump- “it l‘-i .) ml I. .II' Ill-Ill | Via ii'nlii-rl‘il Ill i ill|ll|ll|ll\‘l'- + + + +. . , Linn-1.; u“... + +A Reader’s Guide to Libre Graphics Magazine + +In this magazine. you may find concepts. words. ideas and +things which are new to you. Good. That means your +horizons are expanding. The problem with that, of course. is +that sometimes things with steep learning curves are less fun +than those without. + +That's why we're trying to flatten the learning curve. If. while +reading Libre Graphics magazine. you encounter an unfami ar +word. project name. whatever it may be. chances are good +there's an explanation. + +At the back of this magazine. you'll find a glc ary and +resource list. The glossary aims to define we 5 that are +unique to the world ofLibre Graphics. The resource list +provides valuable information about tools. licenses. whatever +items we may be mentioning. + +Practically. this means that if. for example. you're reading an +article about Paper.js (see pages 30 and '31). you can alwc + +flip to the back of the magazine. look up Paperjs in the +resource list and become quickly informed about it. This +provides some instant gratification. giving you the resources +you need to understand. in a moment. just what we‘re tallxii ‘ +about. + +We hope you like our system. + +Images under other li- (‘ll\1‘\ + +l’linlu‘. HI [lepaii ls" l“ ,‘l lx\ lniiiiim Harlem-s .iir iiIi-ler\ \‘ \k’ \-\ Him ueic‘ +['lll‘ll‘.'ll‘il lll'll' \\lllt lllt’ llt'HlIHsIUH iii ilu‘ll .nillini + +«minim- ~. lil'yI‘ imagi- iiml m'liml .il Mil' l-x \\ Ikiiiietlm iisei llieiimli lion-(i l\ in (he +lllll'llk ilniimiii .llhl l .Iii ln‘ imiinl .ii + +llll" A:vll|ilh‘ll\ \\|l\lll\l'\l|.l wig \\iki tile“ \lnilviil Nautical (”lupin Row pm: + +t-i-m'ml +‘\-l\l'lilv(‘lll1'l|l\ \\|lll llic r‘\i(‘|rlll'll n! Hui-.r' “Tie-muting l il-ic \liaplin s Hagaluw. .Ils‘ +iml IN“ i‘-.Illl\ -iv\('1l'\| lu the blanket i L in \~\ il: ruse ll h lit-st in \ hei L \ulii the + +'llil’K‘l I» lln‘v ll'l'lr'd‘lll lic‘lI-n‘ ir'uullig llH‘llI + + + + +in + +” EDITOR'S LETTE + +i.i.i: Liruii If" ’ + +Editor's letter + +ginger coons + +\K'e so often draw a strong distinction between the physical +and the digital. acting as ifthe one is solid. staid and reliable. +while the other is born in ether. unreal and untouchable. This +is far from the case. Not only on occasion. but always. the +physical and the digital are intimately intertwined. + +The digital is merely a subset of the physical. It is a land we've +come to view as different and distinct. despite its reliance on + +the physical. Regardless ot‘our perceptions. the two tick along. + +happily o-operating and relying on one another. As the +digital fails to esCape the bounds of the physical. the physical +comes to embrace its part in the success of the digital. + +I vraphic design and media arts are fields Well atquainted with +the obvious areas oi overlap between the phv. cal and the +digital. From the days of air brushing and drafting by hand. +to the bringing of those same metaphors into the realm of +digital production. designers :tllCl media artists are at the +l'orvlront of both the conilicts and the embraces ol the digital +and the ['ilI\“sI(.'.il, + +\‘x'l‘n-thr-r it lI‘Idl]lli“--l‘-fi itsr-ll' III .1 worktlow innirporatiiig lmilI + +(ll‘c‘Iiul .ii‘nl [il'iVHIMIl I'i‘Ii'llimlS. lo ilIHi‘I'i‘lit Hills HI' WllcllM'I' It Is +.i lI'.II‘i‘-l|iI‘II‘IiiiIiIH which takes plan- iii the slim c lH‘th‘i‘lI tlic +l’i.‘.‘«i I‘i‘.ilI’I’i:-.. llll' point til IIIii'I‘m‘lIliII llt‘lWi'I'II tllt' tllLL’JiJl .Ill(l + +the physical is a special place. And it bears exploring. + +F Loss graphics and art fields are taking up that exploration in +magnificent ways. In the world of F toss. the space where the +digital and the physical collide is becoming beautifully +populated. + +This issue of Litre Graphics magazine is about border caSes. +the role ofintentionality and happy ' cident in the mingling +of physical and digital. and any and a .l points of intersection. +We're exploring the translation from the digital to the +physical. the phys' ‘al to the digital and the careful mapping of +the two. We're looking at the pl‘dkt‘ oi history and the promise +of the future in harmoniously melding our media. + +We‘re looking at tolds. sprays. cuts and prints. We‘re looking +.it mapping worlds onto each other. In short, in this issue. +we're looking .it collisions: + + + \ No newline at end of file diff --git a/src/soundtotext.py b/src/soundtotext.py new file mode 100644 index 0000000..6f1b2d6 --- /dev/null +++ b/src/soundtotext.py @@ -0,0 +1,2 @@ +o=open('output/sound.wav', 'r') +original = o.read() \ No newline at end of file From 3cd30d75a5701d36b623fedb0293a00d93520ff0 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 5 Mar 2018 09:25:51 +0100 Subject: [PATCH 2/4] added ocr to dirs --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 17be5f9..090dfce 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ clean: ## removes output (target) files dirs: ## create the dirs in working dir @-mkdir -p images/ @-mkdir -p output/ + @-mkdir -p ocr/ @echo $(color_r)'Directories made': images/ output/ @@ -60,7 +61,7 @@ output/tagged-words.txt: ocr/output.txt ## Analyzes OCR'ed text using a Part of # >>> import nltk # >>> nltk.download('averaged_perceptron_tagger') -output/chatbot.txt: ocr/output.txt ## DESCRIBE WHAT IT DOES. Dependencies: python3's chatterbot +output/chatbot.txt: ocr/output.txt ## Comments a text with a simple chatbot. Dependencies: python3's chatterbot cat $< | python3 src/textbotconversation.py $(@) From 89e8436cd0d2e145d1abd70f68c5b99a663d4b47 Mon Sep 17 00:00:00 2001 From: jvdhorst Date: Tue, 6 Mar 2018 14:09:26 +0100 Subject: [PATCH 3/4] Rewrote script to make use of functions. --- .DS_Store | Bin 0 -> 6148 bytes src/wordtagger.py | 127 +++++++++++++++++++++++++--------------------- 2 files changed, 69 insertions(+), 58 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7855ac459e100acc02c8d7fa4e3a813684848e9f GIT binary patch literal 6148 zcmeHK%}T>S5T3QQCW_dDpm^Ggw;ob|svd+;>%p54(Su4&Y-s~EktVfht>iuQjeG!K z$C=$xtW{4UqB}7A&Hl_T^TF=y0D!3W8fAbY09dGm`DtuE5Sk|)lL;QlBMP-g6Oy2x zTn3#u7+Y-y3-0fjV3NRISQjj+^@#HsFA3B zJUyWfsu!0AgZ0WrNtV~Ph9x;DZ#oWkoDF9Nf<>0lo|Sg&u?dkpaFe*35ql z-o$JeFbsUj0KE?qmC$9(G^(cq8&v`z(l Date: Mon, 19 Mar 2018 18:33:18 +0100 Subject: [PATCH 4/4] Added ttssr-human-only --- Makefile | 7 +- ocr/list.txt | 4 - ocr/output.txt | 199 ----------------------------------- src/audio_transcribe.py | 92 ++++++++++++++++ src/soundtotext.py | 2 - src/ttssr-loop-human-only.sh | 18 ++++ src/write_audio.py | 25 +++++ 7 files changed, 138 insertions(+), 209 deletions(-) delete mode 100644 ocr/list.txt delete mode 100644 ocr/output.txt create mode 100644 src/audio_transcribe.py delete mode 100644 src/soundtotext.py create mode 100644 src/ttssr-loop-human-only.sh create mode 100644 src/write_audio.py diff --git a/Makefile b/Makefile index c062555..e245408 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,6 @@ tts: output/chatbot.txt ocr/output.txt ## text to speech. Dependencies: espea @echo $(color_w) cat $? | espeak -ttstt: ocr/output.txt##text to speech, speech to text - cat $< | espeak -s 140 -v f2 --stdout > output/sound.wav - - + +ttssr-human-only: ocr/output.txt ## Loop: text to speech-speech recognition. Dependencies: espeak, pocketsphinx + bash src/ttssr-loop-human-only.sh ocr/output.txt \ No newline at end of file diff --git a/ocr/list.txt b/ocr/list.txt deleted file mode 100644 index 887fc17..0000000 --- a/ocr/list.txt +++ /dev/null @@ -1,4 +0,0 @@ - -images/0004.jpg -images/0006.jpg - diff --git a/ocr/output.txt b/ocr/output.txt deleted file mode 100644 index 3b35384..0000000 --- a/ocr/output.txt +++ /dev/null @@ -1,199 +0,0 @@ - - - - -[J MASTHEAD -int-F urniu . : .“l’ll' 'J - -Masthead - -Editorial Team -Ana (liruilhu -gmger twins - -Ritardo Lat-Liente - -Copy editor - -Margaret Burnett - -Pubfisher - -ginger (001’!g - -Community Board -Dave Crossland - -Louis Desmrdms - -AVTTIt'TlL Hansoux - -Alexandre Prokoudine - -Femke Snelting - -Contributors -Daxe Crossland. Maria Figueiredo, Nelson Concalves. Eric de - -Haas Richard Hugheslonathan Puckey, Eric behriiver - -Printed in Port. by Crornotema (http: troinotemapt) and in -T: into M Green Printer (http’ v.wwgreenprinteronlinc-.4 om‘l - -in rerwled paper - -Lli ensed under at redinek ummons Attril-u’iioi‘i-Rhare Alike -lli r‘l'lv: N l rmrsm '\|l . (Intent \hlluld be attributed to II\ -iridiuidiial lUlhIlT all . ante-m \titl‘i-iut :1 stated author 4 (iii lm - -'TE‘dlir-diiiLilitf‘lrir.1[il]ii\ Hagar”):- - -Contacts - -»\ Hi" to u .1! Hlllllllilv“.iiI‘lll11{"L“i.jplili trying i an: - -HTTP: LIBRFl iRAl’Hll 'beU i.( HM - -Images under a ( (' Attribution Sharr- Aliki- “1 Nine - -l’lmii- mi piii‘gvi Vll‘l’)‘, lit, lii-i- all - -I'll ill. u-l Iv’u ii-lu l .illll‘lil“ liv. "\im‘ .ir'..illi“lllliv li-llll‘ ’i "il'|' .Iiililll<.llllil‘dllillilllt‘illl‘llH‘ili‘JluIi‘ iiu-iiliniiiul - -ilu'iu-m ".li ~lli ll‘l'll’l'll'l l‘vi Milt Ilii l'ul'lillilll ml llIV'.|Vl lilgliliinni lll lll" .llllv ll‘ - -lei.‘ ,t‘miiln. .l‘li‘ it il l 'lliltlllI‘ R‘.lll\ ll yr lli rim .1 lllltll‘l (i H» -lllii‘,li,illlili'. iii Jul-la Illil“".lll-lll,i1llil 5pm. .m lllll'l\ll .\ .'.llll loin | l'r lmri -li, l'llll l l i lllll'l -l'li I- ill ' “l'4ll||l)_ lilliii ' llii l l"|i|-ii‘llilli \.ilil-I.iliiiii \‘rlil lix l-'ii ll-Illl lllll‘lllv“. - -Lin, lump- “it l‘-i .) ml I. .II' Ill-Ill | Via ii'nlii-rl‘il Ill i ill|ll|ll|ll\‘l'- - - - -. . , Linn-1.; u“... - -A Reader’s Guide to Libre Graphics Magazine - -In this magazine. you may find concepts. words. ideas and -things which are new to you. Good. That means your -horizons are expanding. The problem with that, of course. is -that sometimes things with steep learning curves are less fun -than those without. - -That's why we're trying to flatten the learning curve. If. while -reading Libre Graphics magazine. you encounter an unfami ar -word. project name. whatever it may be. chances are good -there's an explanation. - -At the back of this magazine. you'll find a glc ary and -resource list. The glossary aims to define we 5 that are -unique to the world ofLibre Graphics. The resource list -provides valuable information about tools. licenses. whatever -items we may be mentioning. - -Practically. this means that if. for example. you're reading an -article about Paper.js (see pages 30 and '31). you can alwc - -flip to the back of the magazine. look up Paperjs in the -resource list and become quickly informed about it. This -provides some instant gratification. giving you the resources -you need to understand. in a moment. just what we‘re tallxii ‘ -about. - -We hope you like our system. - -Images under other li- (‘ll\1‘\ - -l’linlu‘. HI [lepaii ls" l“ ,‘l lx\ lniiiiim Harlem-s .iir iiIi-ler\ \‘ \k’ \-\ Him ueic‘ -['lll‘ll‘.'ll‘il lll'll' \\lllt lllt’ llt'HlIHsIUH iii ilu‘ll .nillini - -«minim- ~. lil'yI‘ imagi- iiml m'liml .il Mil' l-x \\ Ikiiiietlm iisei llieiimli lion-(i l\ in (he -lllll'llk ilniimiii .llhl l .Iii ln‘ imiinl .ii - -llll" A:vll|ilh‘ll\ \\|l\lll\l'\l|.l wig \\iki tile“ \lnilviil Nautical (”lupin Row pm: - -t-i-m'ml -‘\-l\l'lilv(‘lll1'l|l\ \\|lll llic r‘\i(‘|rlll'll n! Hui-.r' “Tie-muting l il-ic \liaplin s Hagaluw. .Ils‘ -iml IN“ i‘-.Illl\ -iv\('1l'\| lu the blanket i L in \~\ il: ruse ll h lit-st in \ hei L \ulii the - -'llil’K‘l I» lln‘v ll'l'lr'd‘lll lic‘lI-n‘ ir'uullig llH‘llI - - - - -in - -” EDITOR'S LETTE - -i.i.i: Liruii If" ’ - -Editor's letter - -ginger coons - -\K'e so often draw a strong distinction between the physical -and the digital. acting as ifthe one is solid. staid and reliable. -while the other is born in ether. unreal and untouchable. This -is far from the case. Not only on occasion. but always. the -physical and the digital are intimately intertwined. - -The digital is merely a subset of the physical. It is a land we've -come to view as different and distinct. despite its reliance on - -the physical. Regardless ot‘our perceptions. the two tick along. - -happily o-operating and relying on one another. As the -digital fails to esCape the bounds of the physical. the physical -comes to embrace its part in the success of the digital. - -I vraphic design and media arts are fields Well atquainted with -the obvious areas oi overlap between the phv. cal and the -digital. From the days of air brushing and drafting by hand. -to the bringing of those same metaphors into the realm of -digital production. designers :tllCl media artists are at the -l'orvlront of both the conilicts and the embraces ol the digital -and the ['ilI\“sI(.'.il, - -\‘x'l‘n-thr-r it lI‘Idl]lli“--l‘-fi itsr-ll' III .1 worktlow innirporatiiig lmilI - -(ll‘c‘Iiul .ii‘nl [il'iVHIMIl I'i‘Ii'llimlS. lo ilIHi‘I'i‘lit Hills HI' WllcllM'I' It Is -.i lI'.II‘i‘-l|iI‘II‘IiiiIiIH which takes plan- iii the slim c lH‘th‘i‘lI tlic -l’i.‘.‘«i I‘i‘.ilI’I’i:-.. llll' point til IIIii'I‘m‘lIliII llt‘lWi'I'II tllt' tllLL’JiJl .Ill(l - -the physical is a special place. And it bears exploring. - -F Loss graphics and art fields are taking up that exploration in -magnificent ways. In the world of F toss. the space where the -digital and the physical collide is becoming beautifully -populated. - -This issue of Litre Graphics magazine is about border caSes. -the role ofintentionality and happy ' cident in the mingling -of physical and digital. and any and a .l points of intersection. -We're exploring the translation from the digital to the -physical. the phys' ‘al to the digital and the careful mapping of -the two. We're looking at the pl‘dkt‘ oi history and the promise -of the future in harmoniously melding our media. - -We‘re looking at tolds. sprays. cuts and prints. We‘re looking -.it mapping worlds onto each other. In short, in this issue. -we're looking .it collisions: - - - \ No newline at end of file diff --git a/src/audio_transcribe.py b/src/audio_transcribe.py new file mode 100644 index 0000000..3d19528 --- /dev/null +++ b/src/audio_transcribe.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 + +import speech_recognition as sr +import sys +from termcolor import cprint, colored +# obtain path to "english.wav" in the same folder as this script +from os import path +import random + +a1 = sys.argv[1] #same as $1 so when you run python3 audio_transcribe.py FOO ... argv[1] is FOO +# print ("transcribing", a1, file=sys.stderr) +AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), a1) # before it was english.wav +# AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "french.aiff") +# AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "chinese.flac") + +# print (AUDIO_FILE) +# use the audio file as the audio source +r = sr.Recognizer() +with sr.AudioFile(AUDIO_FILE) as source: + audio = r.record(source) # read the entire audio file + +color = ["white", "yellow"] +on_color = ["on_red", "on_magenta", "on_blue", "on_grey"] +# recognize speech using Sphinx + +try: + cprint( r.recognize_sphinx(audio), random.choice(color), random.choice(on_color)) + # print( r.recognize_sphinx(audio)) +except sr.UnknownValueError: + print("uknown") +except sr.RequestError as e: + print("Sphinx error; {0}".format(e)) + +# sleep (1) + +# # recognize speech using Google Speech Recognition +# try: +# # for testing purposes, we're just using the default API key +# # to use another API key, use `r.recognize_google(audio, key="GOOGLE_SPEECH_RECOGNITION_API_KEY")` +# # instead of `r.recognize_google(audio)` +# print("Google Speech Recognition thinks you said " + r.recognize_google(audio)) +# except sr.UnknownValueError: +# print("Google Speech Recognition could not understand audio") +# except sr.RequestError as e: +# print("Could not request results from Google Speech Recognition service; {0}".format(e)) + +# # recognize speech using Google Cloud Speech +# GOOGLE_CLOUD_SPEECH_CREDENTIALS = r"""INSERT THE CONTENTS OF THE GOOGLE CLOUD SPEECH JSON CREDENTIALS FILE HERE""" +# try: +# print("Google Cloud Speech thinks you said " + r.recognize_google_cloud(audio, credentials_json=GOOGLE_CLOUD_SPEECH_CREDENTIALS)) +# except sr.UnknownValueError: +# print("Google Cloud Speech could not understand audio") +# except sr.RequestError as e: +# print("Could not request results from Google Cloud Speech service; {0}".format(e)) + +# # recognize speech using Wit.ai +# WIT_AI_KEY = "INSERT WIT.AI API KEY HERE" # Wit.ai keys are 32-character uppercase alphanumeric strings +# try: +# print("Wit.ai thinks you said " + r.recognize_wit(audio, key=WIT_AI_KEY)) +# except sr.UnknownValueError: +# print("Wit.ai could not understand audio") +# except sr.RequestError as e: +# print("Could not request results from Wit.ai service; {0}".format(e)) + +# # recognize speech using Microsoft Bing Voice Recognition +# BING_KEY = "INSERT BING API KEY HERE" # Microsoft Bing Voice Recognition API keys 32-character lowercase hexadecimal strings +# try: +# print("Microsoft Bing Voice Recognition thinks you said " + r.recognize_bing(audio, key=BING_KEY)) +# except sr.UnknownValueError: +# print("Microsoft Bing Voice Recognition could not understand audio") +# except sr.RequestError as e: +# print("Could not request results from Microsoft Bing Voice Recognition service; {0}".format(e)) + +# # recognize speech using Houndify +# HOUNDIFY_CLIENT_ID = "INSERT HOUNDIFY CLIENT ID HERE" # Houndify client IDs are Base64-encoded strings +# HOUNDIFY_CLIENT_KEY = "INSERT HOUNDIFY CLIENT KEY HERE" # Houndify client keys are Base64-encoded strings +# try: +# print("Houndify thinks you said " + r.recognize_houndify(audio, client_id=HOUNDIFY_CLIENT_ID, client_key=HOUNDIFY_CLIENT_KEY)) +# except sr.UnknownValueError: +# print("Houndify could not understand audio") +# except sr.RequestError as e: +# print("Could not request results from Houndify service; {0}".format(e)) + +# # recognize speech using IBM Speech to Text +# IBM_USERNAME = "INSERT IBM SPEECH TO TEXT USERNAME HERE" # IBM Speech to Text usernames are strings of the form XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX +# IBM_PASSWORD = "INSERT IBM SPEECH TO TEXT PASSWORD HERE" # IBM Speech to Text passwords are mixed-case alphanumeric strings +# try: +# print("IBM Speech to Text thinks you said " + r.recognize_ibm(audio, username=IBM_USERNAME, password=IBM_PASSWORD)) +# except sr.UnknownValueError: +# print("IBM Speech to Text could not understand audio") +# except sr.RequestError as e: +# print("Could not request results from IBM Speech to Text service; {0}".format(e)) diff --git a/src/soundtotext.py b/src/soundtotext.py deleted file mode 100644 index 6f1b2d6..0000000 --- a/src/soundtotext.py +++ /dev/null @@ -1,2 +0,0 @@ -o=open('output/sound.wav', 'r') -original = o.read() \ No newline at end of file diff --git a/src/ttssr-loop-human-only.sh b/src/ttssr-loop-human-only.sh new file mode 100644 index 0000000..5ff596a --- /dev/null +++ b/src/ttssr-loop-human-only.sh @@ -0,0 +1,18 @@ +#!/bin/bash +i=0; +#cp $1 output/input0.txt +echo "Read every new sentence out loud!" +head -n 1 $1 > output/input0.txt +while [[ $i -le 10 ]] + do echo $i + cat output/input$i.txt + python3 src/write_audio.py src/sound$i.wav 2> /dev/null + play src/sound$i.wav repeat 5 2> /dev/null & #in the background the sound, without it all the sounds play one by one//2 is stderr + python3 src/audio_transcribe.py sound$i.wav > output/input$((i+1)).txt 2> /dev/null + sleep + (( i++ )) +done +today=$(date +%Y-%m-%d); +mkdir -p "output/ttssr.$today" +mv -v output/input* output/ttssr.$today; +mv -v src/sound* output/ttssr.$today; diff --git a/src/write_audio.py b/src/write_audio.py new file mode 100644 index 0000000..1f8bc61 --- /dev/null +++ b/src/write_audio.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# https://github.com/Uberi/speech_recognition/blob/master/examples/write_audio.py +# NOTE: this example requires PyAudio because it uses the Microphone class + +import speech_recognition as sr +import sys +from time import sleep + +a1 = sys.argv[1] + +# obtain audio from the microphone +r = sr.Recognizer() +with sr.Microphone() as source: + # print("Read every new sentence out loud!") + audio = r.listen(source) + +# sleep (1) +# +# # write audio to a RAW file +# with open("microphone-results.raw", "wb") as f: +# f.write(audio.get_raw_data()) + +# write audio to a WAV file +with open(a1, "wb") as f: + f.write(audio.get_wav_data()) \ No newline at end of file