Skip to content
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
4 changes: 2 additions & 2 deletions virtual-assistant-rasa/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
'''
Expand Down
2 changes: 1 addition & 1 deletion virtual-assistant-rasa/rasa-riva-weatherbot-webapp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion virtual-assistant-rasa/rasa-weatherbot/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions virtual-assistant-rasa/rasa-weatherbot/riva_local/nlp/nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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(".")
Expand All @@ -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", "")
Expand Down Expand Up @@ -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"
Expand Down