Skip to content

added a python voice program to provide voice to the result of the model #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions neuralintents/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pickle
import numpy as np
import os
import voice

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

Expand Down Expand Up @@ -55,7 +56,8 @@ def __init__(self, intents, intent_methods={}, model_name="assistant_model"):
self.lemmatizer = WordNetLemmatizer()

def load_json_intents(self, intents):
self.intents = json.loads(open(intents).read())
json_file = open("intents.json")
self.intents = json.load(json_file)

def train_model(self):

Expand Down Expand Up @@ -184,4 +186,4 @@ def request(self, message):
if ints[0]['intent'] in self.intent_methods.keys():
self.intent_methods[ints[0]['intent']]()
else:
return self._get_response(ints, self.intents)
voice.say(self._get_response(ints, self.intents))
8 changes: 8 additions & 0 deletions neuralintents/voice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import pyttsx3
engine=pyttsx3.init()
voices=engine.getProperty('voices')
engine.setProperty('voices',voices[0].id)
def say(audiostring):
print(audiostring)
engine.say(audiostring)
engine.runAndWait()