Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
import argparse
import epitran
def get_phoneme_string(epi,word):
phoneme_tuples = epi.word_to_tuples(word)
num = 0
phoneme_list = []
while num < len(phoneme_tuples):
@Witty-Kitty
Witty-Kitty / word_frequencies_for_tts.py
Last active April 11, 2023 15:43
Word Frequencies for TTS
#!/usr/bin/env python3
import argparse
from collections import Counter
from pathlib import Path
import string
def word_frequency(text_directory: Path) -> Counter:
"""Get the word frequency table for a directory of text files."""
@Witty-Kitty
Witty-Kitty / family-rw-en
Last active June 25, 2019 11:42
kinyarwanda-english-wordlist
baba data - my father
baba iso - your father
baba ise - his/her father
mama mama - my mother
mama nyoko - your mother
mama nyina - his/her mother
kaka musaza - my brother(girl)
kaka mukuru - older brother(boy)
kaka murumuna - younger brother(boy)
dada mushiki - sister to a boy
@Witty-Kitty
Witty-Kitty / alp_visualize_lg_rw_vectors.py
Created February 18, 2019 16:38
Read in word vectors and visualize using TSNE
import gensim
from sklearn.manifold import TSNE
import matplotlib.pyplot as plt
model = gensim.models.KeyedVectors.load_word2vec_format('MUSE/dumped/debug/8gywilp7r1/vectors-rw1.txt')
model2 = gensim.models.KeyedVectors.load_word2vec_format('MUSE/dumped/debug/8gywilp7r1/vectors-lg1.txt')
lg_dict = {
"katonda": "god",
"emu": "one",
@Witty-Kitty
Witty-Kitty / alp_data_prep.py
Created February 18, 2019 11:54
Text pre-processing
import nltk
from nltk.tokenize import word_tokenize
from nltk.text import Text
# read in text data
file = open("crawl-for-parallel-corpora/DataSet/luganda.txt", "r")
raw = file.read()
# tokenize
tokens = word_tokenize(raw)
@Witty-Kitty
Witty-Kitty / BaseConverterActivity.java
Created December 31, 2014 20:43
The following are source code files for an android program that converts numbers from decimal to their binary digits as well as giving step by syep instructions of how this occurs.
package com.example.baseconverter;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;