This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import uuid | |
from sanic import Blueprint, response | |
from sanic.request import Request | |
from socketio import AsyncServer | |
from typing import Optional, Text, Any, List, Dict, Iterable | |
from rasa.core.channels.channel import InputChannel | |
from rasa.core.channels.channel import UserMessage, OutputChannel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rasa.nlu.components import Component | |
from rasa.nlu import utils | |
from rasa.nlu.model import Metadata | |
import nltk | |
from nltk.sentiment.vader import SentimentIntensityAnalyzer | |
import os | |
class SentimentAnalyzer(Component): | |
"""A pre-trained sentiment component""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Action Server | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- 'actions/**' | |
jobs: | |
my_first_job: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyaudio | |
from deepspeech import Model | |
import scipy.io.wavfile as wav | |
import wave | |
WAVE_OUTPUT_FILENAME = "test_audio.wav" | |
def record_audio(WAVE_OUTPUT_FILENAME): | |
CHUNK = 1024 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rasa.nlu.components import Component | |
from rasa.nlu import utils | |
from rasa.nlu.model import Metadata | |
import nltk | |
from nltk.classify import NaiveBayesClassifier | |
import os | |
import typing | |
from typing import Any, Optional, Text, Dict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate(self, | |
dispatcher: CollectingDispatcher, | |
tracker: Tracker, | |
domain: Dict[Text, Any]) -> List[Dict]: | |
"""Validate extracted requested slot | |
else reject the execution of the form action | |
""" | |
# extract other slots that were not requested | |
# but set by corresponding entity | |
slot_values = self.extract_other_slots(dispatcher, tracker, domain) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import io | |
import torch | |
from collections import OrderedDict | |
from TTS.models.tacotron import Tacotron | |
from TTS.layers import * | |
from TTS.utils.data import * | |
from TTS.utils.audio import AudioProcessor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"actions": [ | |
{ | |
"description": "Default Welcome Intent", | |
"name": "MAIN", | |
"fulfillment": { | |
"conversationName": "welcome" | |
}, | |
"intent": { | |
"name": "actions.intent.MAIN", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@google_webhook.route("/webhook", methods=['POST']) | |
async def receive(request): | |
payload = request.json | |
intent = payload['inputs'][0]['intent'] | |
text = payload['inputs'][0]['rawInputs'][0]['query'] | |
if intent == 'actions.intent.MAIN': | |
message = "Hello! Welcome to the Rasa-powered Google Assistant skill. You can start by saying hi." | |
else: | |
out = CollectingOutputChannel() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@google_webhook.route("/", methods=['GET']) | |
async def health(request): | |
return response.json({"status": "ok"}) |
NewerOlder