From 7fe8d25faae1268540505ee2b4375f27a2fd7608 Mon Sep 17 00:00:00 2001 From: Natasha Berting Date: Wed, 21 Mar 2018 14:46:16 +0100 Subject: [PATCH 1/4] update make tiffs with alpha channel --- .DS_Store | Bin 6148 -> 6148 bytes Makefile | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index 7855ac459e100acc02c8d7fa4e3a813684848e9f..ce48ee8f64ea9cf57524a682c1f2f3dc45a7140a 100644 GIT binary patch delta 202 zcmZoMXffEJ&SLU2sURn_xWvHVCL;NXlG zkf^RUG&R;yFf_KP)lsN6H#g8xFflf-treKX!6B__>gXF;P}{X=@sg#>majN`lmQGF a86h--FqDQ-$AFB@-&h_qZD!~A%MSo+FE;T2 delta 37 tcmZoMXffEJ&N4ZOwS~jf%v?vo(8O}`Jyz$ Date: Wed, 21 Mar 2018 16:14:33 +0100 Subject: [PATCH 2/4] fixed dpi make tiffs --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 23e9ba2..e41f9c0 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,7 @@ tiffs: ## convert images/ to images-tiff/ Depends on IM echo $(images) for i in $(images); \ do tiff=`basename $$i .jpg`.tiff; \ - convert $$i -density 300 -alpha on images-tiff/$$tiff; \ + convert -density 300 $$i -alpha on images-tiff/$$tiff; \ echo $$tiff; \ done; From 13a3edd10df7a3294397a1012e61e689cad36956 Mon Sep 17 00:00:00 2001 From: ange Date: Wed, 21 Mar 2018 17:45:16 +0100 Subject: [PATCH 3/4] Modified ttssr and removed tts recipe --- Makefile | 6 ------ src/ttssr-loop-human-only.sh | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 763be96..e8c33f6 100644 --- a/Makefile +++ b/Makefile @@ -81,11 +81,5 @@ else endif -tts: output/chatbot.txt ocr/output.txt ## text to speech. Dependencies: espeak - @echo $(color_r) speaking $? - @echo $(color_w) - cat $? | espeak - - 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/src/ttssr-loop-human-only.sh b/src/ttssr-loop-human-only.sh index 5ff596a..2b31570 100644 --- a/src/ttssr-loop-human-only.sh +++ b/src/ttssr-loop-human-only.sh @@ -12,7 +12,7 @@ while [[ $i -le 10 ]] sleep (( i++ )) done -today=$(date +%Y-%m-%d); +today=$(date +%Y%m%d.%H-%M); mkdir -p "output/ttssr.$today" mv -v output/input* output/ttssr.$today; mv -v src/sound* output/ttssr.$today; From ad9651e011e756763d56bea9801bd23a6babf14e Mon Sep 17 00:00:00 2001 From: ange Date: Thu, 22 Mar 2018 11:22:10 +0100 Subject: [PATCH 4/4] Cleaned ttssr python/shell scripts --- src/audio_transcribe.py | 65 ++---------------------------------- src/ttssr-loop-human-only.sh | 1 - src/write_audio.py | 4 --- 3 files changed, 3 insertions(+), 67 deletions(-) diff --git a/src/audio_transcribe.py b/src/audio_transcribe.py index 3d19528..ed07a99 100644 --- a/src/audio_transcribe.py +++ b/src/audio_transcribe.py @@ -1,19 +1,17 @@ #!/usr/bin/env python3 +# https://github.com/Uberi/speech_recognition/blob/master/examples/audio_transcribe.py 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: @@ -21,8 +19,8 @@ with sr.AudioFile(AUDIO_FILE) as source: color = ["white", "yellow"] on_color = ["on_red", "on_magenta", "on_blue", "on_grey"] -# recognize speech using Sphinx +# recognize speech using Sphinx try: cprint( r.recognize_sphinx(audio), random.choice(color), random.choice(on_color)) # print( r.recognize_sphinx(audio)) @@ -33,60 +31,3 @@ except sr.RequestError as 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/ttssr-loop-human-only.sh b/src/ttssr-loop-human-only.sh index 2b31570..6a098ce 100644 --- a/src/ttssr-loop-human-only.sh +++ b/src/ttssr-loop-human-only.sh @@ -1,6 +1,5 @@ #!/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 ]] diff --git a/src/write_audio.py b/src/write_audio.py index 1f8bc61..9b6cf95 100644 --- a/src/write_audio.py +++ b/src/write_audio.py @@ -15,10 +15,6 @@ with sr.Microphone() as source: 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: