diff --git a/virtual-assistant-rasa/config.py b/virtual-assistant-rasa/config.py index 2fa4b42..4010501 100644 --- a/virtual-assistant-rasa/config.py +++ b/virtual-assistant-rasa/config.py @@ -19,12 +19,12 @@ } rasa_config = { - "VERBOSE": False, # Print logs/details for diagnostics + "VERBOSE": True, # Print logs/details for diagnostics "RASA_API_URL": "http://localhost:5005", # Replace the IP & Port with the rasa-weatherbot's IP & Port } asr_config = { - "VERBOSE": False, # Print logs/details for diagnostics + "VERBOSE": True, # Print logs/details for diagnostics "SAMPLING_RATE": 16000, # The Sampling Rate for the audio input file. The only value currently supported is 16000 "LANGUAGE_CODE": "en-US", # The language code as a BCP-47 language tag. The only value currently supported is "en-US" "ENABLE_AUTOMATIC_PUNCTUATION": True, # Enable or Disable punctuation in the transcript generated. The only value currently supported by the chatbot is True (Although Riva ASR supports both True & False) diff --git a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/client/webapplication/server/server.py b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/client/webapplication/server/server.py index a1c6293..cba4223 100644 --- a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/client/webapplication/server/server.py +++ b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/client/webapplication/server/server.py @@ -19,7 +19,7 @@ from engineio.payload import Payload from config import client_config -from riva.chatbot.chatbots_multiconversations_management import create_chatbot, get_new_user_conversation_index, get_chatbot +from riva_local.chatbot.chatbots_multiconversations_management import create_chatbot, get_new_user_conversation_index, get_chatbot ''' Flask Initialization ''' diff --git a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/main.py b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/main.py index b68d42b..5705b3e 100644 --- a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/main.py +++ b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/main.py @@ -9,7 +9,7 @@ root_folder = (os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))) sys.path.append(root_folder) - +# print(root_folder) from config import client_config if __name__ == '__main__': diff --git a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/chatbot/chatbot.py b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/chatbot/chatbot.py index 601eacc..3131fae 100644 --- a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/chatbot/chatbot.py +++ b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/chatbot/chatbot.py @@ -9,8 +9,8 @@ from riva_local.asr.asr import ASRPipe from riva_local.rasa.rasa import RASAPipe -from riva_local.tts.tts import TTSPipe -# from riva_local.tts.tts_stream import TTSPipe +# from riva_local.tts.tts import TTSPipe +from riva_local.tts.tts_stream import TTSPipe class ChatBot(object): """ Class Implementing all the features of the chatbot""" diff --git a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts.py b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts.py index f37d0fd..fa95494 100644 --- a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts.py +++ b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts.py @@ -27,7 +27,7 @@ def __init__(self): self.sample_rate = tts_config["SAMPLE_RATE"] if "SAMPLE_RATE" in tts_config else SAMPLE_RATE self.language_code = tts_config["LANGUAGE_CODE"] if "LANGUAGE_CODE" in tts_config else LANGUAGE_CODE self.voice_name = tts_config["VOICE_NAME"] if "VOICE_NAME" in tts_config else VOICE_NAME - self.audio_encoding = ra.AudioEncoding.LINEAR_PCM + self.audio_encoding = riva.client.AudioEncoding.LINEAR_PCM self._buff = queue.Queue() self.closed = False self._flusher = bytes(np.zeros(dtype=np.int16, shape=(self.sample_rate, 1))) # Silence audio diff --git a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts_stream.py b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts_stream.py index 2dfe0cc..cf705d7 100644 --- a/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts_stream.py +++ b/virtual-assistant-rasa/rasa-riva-weatherbot-webapp/riva_local/tts/tts_stream.py @@ -22,7 +22,7 @@ class TTSPipe(object): """Opens a gRPC channel to Riva TTS to synthesize speech from text in streaming mode.""" - + print('TTS started') def __init__(self): self.verbose = tts_config["VERBOSE"] if "VERBOSE" in tts_config else VERBOSE self.sample_rate = tts_config["SAMPLE_RATE"] if "SAMPLE_RATE" in tts_config else SAMPLE_RATE @@ -48,6 +48,7 @@ def get_current_tts_duration(self): def fill_buffer(self, in_data): """To collect text responses from the state machine output, into a buffer.""" + # print() if len(in_data): self._buff.put(in_data) diff --git a/virtual-assistant-rasa/rasa-weatherbot/components.py b/virtual-assistant-rasa/rasa-weatherbot/components.py index 4943c72..6c1b3b5 100644 --- a/virtual-assistant-rasa/rasa-weatherbot/components.py +++ b/virtual-assistant-rasa/rasa-weatherbot/components.py @@ -21,7 +21,7 @@ os.path.pardir))) sys.path.append(root_folder) -from riva.nlp.nlp import get_intent_and_entities +from riva_local.nlp.nlp import get_intent_and_entities class RivaNLPComponent(Component): @@ -83,6 +83,7 @@ def __convert_to_rasa_intent(self, response): return intent def __convert_to_rasa_entities(self, response): + print(response) """Convert model output into the Rasa NLU compatible output format.""" for entity in response["entities"]: entity["extractor"] = "RivaNLPExtractor" diff --git a/virtual-assistant-rasa/rasa-weatherbot/riva_local/nlp/nlp.py b/virtual-assistant-rasa/rasa-weatherbot/riva_local/nlp/nlp.py index ae1b61f..924784f 100644 --- a/virtual-assistant-rasa/rasa-weatherbot/riva_local/nlp/nlp.py +++ b/virtual-assistant-rasa/rasa-weatherbot/riva_local/nlp/nlp.py @@ -18,7 +18,7 @@ import json auth = riva.client.Auth(uri=riva_config["RIVA_SPEECH_API_URL"]) -riva_nlp = riva.client.NLPService(auth) +riva_nlp = riva.client.NLPService(auth) # The default intent object for specifying the city SPECIFY_CITY_INTENT = { 'value': "specify_city", 'confidence': 1 } @@ -31,8 +31,9 @@ verbose = rivanlp_config["VERBOSE"] if "VERBOSE" in rivanlp_config else VERBOSE nlu_fallback_threshold = rivanlp_config["NLU_FALLBACK_THRESHOLD"] if "NLU_FALLBACK_THRESHOLD" in rivanlp_config else NLU_FALLBACK_THRESHOLD - +# {} def get_intent_old(resp, result): + # result['intent'] = [] if hasattr(resp, 'intent') and (hasattr(resp, 'domain') and resp.domain.class_name != "nomatch.none"): result['intent'] = { 'value': resp.intent.class_name, 'confidence': resp.intent.score } parentclassintent_index = result['intent']['value'].find(".") @@ -51,6 +52,7 @@ def get_entities(resp, result): location_found_flag = False all_entities_class = {} all_entities = [] + result['entities'] = [] if hasattr(resp, 'slots'): for i in range(len(resp.slots)): slot_class = resp.slots[i].label[0].class_name.replace("\r", "") @@ -110,8 +112,8 @@ def get_riva_output(text): print("[Riva NLU] Error during NLU request") return {'riva_error': 'riva_error'} entities = {} - get_intent(resp, entities) - get_slots(resp, entities) + get_intent_old(resp, entities) + get_entities(resp, entities) if 'location' not in entities: if verbose: print(f"[Riva NLU] Did not find any location in the string: {text}\n"