Skip to content

Instantly share code, notes, and snippets.

Avatar

Justina Petraityte JustinaPetr

View GitHub Profile
View custom_action_server.yml
name: Action Server
on:
push:
branches:
- 'main'
paths:
- 'actions/**'
jobs:
my_first_job:
View socketio_connector.py
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
View test_tts.py
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
View deepspeech_test_prediction.py
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
View sentiment_starter.py
from rasa.nlu.components import Component
class SentimentAnalyzer(Component):
"""A pre-trained sentiment component"""
name = "sentiment"
provides = ["entities"]
requires = ["tokens"]
defaults = {}
language_list = ["en"]
View gist:600eb14eab19997cf5129b159e9fa677
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"""
View sentiment.py
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
View sentiment.py
from rasa_nlu.components import Component
from rasa_nlu import utils
from rasa_nlu.model import Metadata
from sentiment_classifier import SentimentClassifier
import nltk
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import twitter_samples
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
View sentiment_classifier.py
import nltk
from nltk.classify import NaiveBayesClassifier
from nltk.corpus import twitter_samples
from nltk.tokenize import RegexpTokenizer
from nltk.corpus import stopwords
from nltk.stem.wordnet import WordNetLemmatizer
class SentimentClassifier(object):
View form_validate.py
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)