Skip to content

Commit

Permalink
Connected Everything
Browse files Browse the repository at this point in the history
  • Loading branch information
varunk122 committed Jul 5, 2020
1 parent 1fd9c3b commit efce2da
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
Binary file added Output.mp3
Binary file not shown.
11 changes: 11 additions & 0 deletions dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/bash

virtualenv -q -p /usr/bin/python3.5 $1
source $1/bin/activate
$1/bin/pip install -r requirements.txt

python3 -m spacy download en

pip install speechRecognition


27 changes: 23 additions & 4 deletions tf_attention_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import numpy as np
import matplotlib.pyplot as plt
from gtts import gTTS

from keras.layers import Bidirectional, Concatenate, Permute, Dot, Input, LSTM, Multiply , Embedding
from keras.layers import RepeatVector, Dense, Activation, Lambda
Expand Down Expand Up @@ -320,6 +321,7 @@ def response(sentence):

# print('Input: %s' % (sentence))
print('Response: {}'.format(result))
return result

# attention_plot = attention_plot[:len(result.split(' ')), :len(sentence.split(' '))]
# plot_attention(attention_plot, sentence.split(' '), result.split(' '))
Expand Down Expand Up @@ -547,17 +549,34 @@ def get_prob(pred):

return output , prob

def string_to_audio(input_string, delete):
language = 'en'
gen_audio = gTTS(text = input_string, lang=language, slow=False)
gen_audio.save("Output.mp3")
os.system("mpg123 output.mp3")
if (delete == True):
os.remove("Output.mp3")


if __name__ == '__main__':

debug = True

r = sr.Recognizer()
with sr.AudioFile( 'examples/voice_2.wav') as source:

audio_text = r.listen(source)
# using google speech recognition

text = r.recognize_google(audio_text)
print('Converting audio transcripts into text ...')
print(text)
if debug == True:

print('Converting audio transcripts into text ...')
print(text)

result = response(text)
beam_search_decoder(text)

string_to_audio(result , False)


(response(text))
beam_search_decoder(text)

0 comments on commit efce2da

Please sign in to comment.