Skip to content

Instantly share code, notes, and snippets.

@nmstoker
nmstoker / treemodel.py
Created April 4, 2023 12:00
TreeModel
from PySide6.QtCore import Qt, QAbstractItemModel, QModelIndex, QVariant
class Node:
def __init__(self, name, parent=None, private_data=None):
self.name = name
self.parentNode = parent
self.childNodes = []
self.privateData = private_data
if parent:
@nmstoker
nmstoker / demo.py
Created May 13, 2020 22:02
Example Python code to call Mozilla TTS demo server's API
import requests
say_text = input('What should I say?')
url = f'http://<REPLACE_WITH_RPI_NETWORK_NAME_IP>:5002/api/tts?text={say_text}' # You will be doing a GET with this format of URL: http://0.0.0.0:5002/api/tts?text=Welcome
r = requests.get(url)
with open('response.wav', 'wb') as f:
f.write(r.content)
print('saved wav for {}'.format(url))
@nmstoker
nmstoker / PersonNameList1.txt
Created August 28, 2019 18:04
Extracted from Wiktionary, filtered to find capitalised words (ie proper nouns) and then manual removed obvious non-person names. It's not perfect and there may well be cases that sound like names, but it's a start :-) Where places were commonly known to be people's names too (eg York) these are included.
Aaron,de,ˈʔaːʀɔn
Aaron,en,ˈɛəˈɹən
Aaron,en,ˈɛɹ.ən
Abbe,sv,²abɛ
Abby,en,ˈæb.i
Abdul,en,ɑbˈdʊl
Abel,en,ˈeɪ.bl̩
Abel,pt,a.ˈbɛw
Abel,pt,a.ˈbɛɫ
Abel,sh,ǎːbel
@nmstoker
nmstoker / Steps.md
Last active June 10, 2019 11:16
Steps to try out DeepSpeech with pre-release 0.5.0a11 model

Downloaded the DeepSpeech GPU wheel for my OS + intended version of Python (3.7)

https://github.com/mozilla/DeepSpeech/releases/download/v0.5.0-alpha.11/deepspeech_gpu-0.5.0a11-cp37-cp37m-manylinux1_x86_64.whl

Downloaded the model (as per link from https://discourse.mozilla.org/t/deep-speech-0-5-0-pre-release-model-checkpoint/41236) and expanded files

https://drive.google.com/file/d/1vNokDsmUdwP9rk1c68JUOS0SCO5lHv3m/view?usp=sharing

Conda environment for DeepSpeech GPU

conda create -n deepspeech_051a11 python=3.7

@nmstoker
nmstoker / convert.py
Created January 11, 2018 00:07
Convert a Rasa NLU training file from JSON to Markdown format
from rasa_nlu.converters import load_data
# This re-uses the Rasa NLU converters code to turn a JSON Rasa NLU training
# file into MD format and save it
# Assumes you have Rasa NLU installed :-)
# If you want other options, look at the NLU code to work out how to handle them
# USE AT YOUR OWN RISK