diff options
| author | yum <yum.food.vr@gmail.com> | 2022-11-10 21:21:07 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2022-11-10 21:21:07 -0800 |
| commit | 772b44806a5f5da11cca74c99b59c3cf7d5ceae5 (patch) | |
| tree | aba2f690b4be58aaa4c0c0f26443ba5085deca63 | |
| parent | 2efc87a7180ec6e92127d22d1a3eb8c44fd392db (diff) | |
License scrub
Begin auditing dependencies' licenses.
| -rw-r--r-- | generate_fonts.py | 2 | ||||
| -rw-r--r-- | libunity.py | 1 | ||||
| -rw-r--r-- | osc_ctrl.py | 3 | ||||
| -rw-r--r-- | string_matcher.py | 9 | ||||
| -rw-r--r-- | transcribe.py | 35 |
5 files changed, 32 insertions, 18 deletions
diff --git a/generate_fonts.py b/generate_fonts.py index 3c3ffb0..6564c09 100644 --- a/generate_fonts.py +++ b/generate_fonts.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +# python3 -m pip install pillow +# License: HPND license. from PIL import Image, ImageFont, ImageDraw import math diff --git a/libunity.py b/libunity.py index 4e5c591..822c238 100644 --- a/libunity.py +++ b/libunity.py @@ -9,6 +9,7 @@ import pickle import random import sys # python3 -m pip install pyyaml +# License: MIT. import yaml import multiprocessing as mp diff --git a/osc_ctrl.py b/osc_ctrl.py index 8cd5571..5fadd6f 100644 --- a/osc_ctrl.py +++ b/osc_ctrl.py @@ -6,7 +6,10 @@ import time import fileinput import generate_utils +# python3 -m pip install python-osc +# License: public domain. from pythonosc import udp_client + from math import ceil from math import floor from generate_utils import getLayerParam diff --git a/string_matcher.py b/string_matcher.py index f3284e9..cf11133 100644 --- a/string_matcher.py +++ b/string_matcher.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 -# python3 -m pip install python-Levenshtein -from Levenshtein import distance as levenshtein_distance +# python3 -m pip install editdistance +# License: MIT. +import editdistance import typing @@ -26,7 +27,7 @@ def matchStringList(old_words: typing.List[str], new_slice = new_words[i:i + window_size] cur_d = 0 for j in range(0, window_size): - cur_d += levenshtein_distance(old_slice[j], new_slice[j]) + cur_d += editdistance.eval(old_slice[j], new_slice[j]) if cur_d < best_match_d: best_match_i = i best_match_d = cur_d @@ -76,7 +77,7 @@ def matchStrings(old_text: str, new_text: str, window_size = 3) -> str: for j in range(0, 1 + len(new_text) - window_size): new_slice = new_text[j:j + window_size] - cur_d = levenshtein_distance(old_slice, new_slice) + cur_d = editdistance.eval(old_slice, new_slice) if cur_d <= best_match_d: best_match_i = i best_match_j = j diff --git a/transcribe.py b/transcribe.py index e96d794..2e4457e 100644 --- a/transcribe.py +++ b/transcribe.py @@ -6,9 +6,11 @@ import string_matcher import os import osc_ctrl # python3 -m pip install pydub +# License: MIT. from pydub import AudioSegment as pydub_AudioSegment from pydub import effects as pydub_effects # python3 -m pip install pyaudio +# License: MIT. import pyaudio import sys import threading @@ -16,6 +18,7 @@ import time import wave # python3 -m pip install git+https://github.com/openai/whisper.git # python3 -m pip install torch -f https://download.pytorch.org/whl/torch_stable.html +# License: MIT. import whisper class AudioState: @@ -270,20 +273,9 @@ def sendAudio(audio_state): # Pace this out time.sleep(0.01) -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("--mic", type=str, help="Which mic to use. Options: index, focusrite. Default: index") - parser.add_argument("--language", type=str, help="Which language to use. Ex: english, japanese, chinese, french, german.") - args = parser.parse_args() - - if not args.mic: - args.mic = "index" - - if not args.language: - args.language = "english" - - audio_state = getMicStream(args.mic) - audio_state.language = whisper.tokenizer.TO_LANGUAGE_CODE[args.language] +def transcribeLoop(mic: str, language: str): + audio_state = getMicStream(mic) + audio_state.language = whisper.tokenizer.TO_LANGUAGE_CODE[language] if os.path.isfile(audio_state.VOICE_AUDIO_FILENAME): # empty out the voice file @@ -318,3 +310,18 @@ if __name__ == "__main__": record_audio_thd.join() transcribe_audio_thd.join() + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--mic", type=str, help="Which mic to use. Options: index, focusrite. Default: index") + parser.add_argument("--language", type=str, help="Which language to use. Ex: english, japanese, chinese, french, german.") + args = parser.parse_args() + + if not args.mic: + args.mic = "index" + + if not args.language: + args.language = "english" + + transcribeLoop(args.mic, args.language) + |
