commit 0eb65e47722906a152330a2426b54f845651a8ea Author: Yannik Schmidt Date: Wed Aug 15 20:56:35 2018 +0200 Initial diff --git a/.plan.txt.swp b/.plan.txt.swp new file mode 100644 index 0000000..302b0db Binary files /dev/null and b/.plan.txt.swp differ diff --git a/plan.txt b/plan.txt new file mode 100644 index 0000000..f465c84 --- /dev/null +++ b/plan.txt @@ -0,0 +1,15 @@ +Smartphone: + - record + - play + - send to server + - recive text form server (?) + +Server: + - revice from smartphone + - use google api for recognition + - process/format result (i.e. templating (i.e. templating)) + - send resulting text + +Computer/Client: + - recivce text + - place it somewhere diff --git a/python-server/.main.py.swp b/python-server/.main.py.swp new file mode 100644 index 0000000..7f85550 Binary files /dev/null and b/python-server/.main.py.swp differ diff --git a/python-server/main.py b/python-server/main.py new file mode 100755 index 0000000..49ccb3b --- /dev/null +++ b/python-server/main.py @@ -0,0 +1,8 @@ +#!/usr/bin/python3 +import s_input +import sys + +if __name__ == "__main__": + path = sys.argv[1] + print("AudioFile: {}".format(path)) + print(s_input.analyse_file_by_path(path)) diff --git a/python-server/s_input.py b/python-server/s_input.py new file mode 100644 index 0000000..bd7a6d4 --- /dev/null +++ b/python-server/s_input.py @@ -0,0 +1,6 @@ +import speech + +def analyse_file_by_path(file_path): + transcript = speech.analyse(file_path) + + return transcript diff --git a/python-server/speech.py b/python-server/speech.py new file mode 100644 index 0000000..206decc --- /dev/null +++ b/python-server/speech.py @@ -0,0 +1,17 @@ +import speech_recognition as spr +def analyse(file_path): + ''' returns the transcripted audio, or None if the analysis fails ''' + recognizer = spr.Recognizer() + with sr.AudioFile(file_path) as source: + audio = r.record(source) + + try: + string = r.recognize_google(audio) + except spr.UnknownValueError: + log.log("Audio file is broken or not an audio file") + return None + except spr.RequestError as e: + log.log("Could not connect to google API: {}".format(e)) + return None + + return string diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..a26e927 --- /dev/null +++ b/setup.sh @@ -0,0 +1,5 @@ +apt-get install python python-all-dev python-pip build-essential swig git libpulse-dev libasound2-dev +pip3 install wheel +pip3 install google-cloud-speech +pip3 install pocketsphin +pip3 install SpeechRecognition diff --git a/test-data/das_ist_ein_test.wav b/test-data/das_ist_ein_test.wav new file mode 100644 index 0000000..789da68 Binary files /dev/null and b/test-data/das_ist_ein_test.wav differ