env: use XDG STATE more widely
This commit is contained in:
parent
d0acf773e8
commit
f0fc69bb90
|
@ -9,15 +9,19 @@ import subprocess
|
|||
|
||||
SetLogLevel(0)
|
||||
|
||||
modelBase = os.path.join(os.getenv('XDG_DATA_HOME', os.environ['HOME']), 'vosk/models')
|
||||
modelBase = os.getenv('VOSK_MODELS', os.path.join(os.getenv('XDG_DATA_HOME', os.environ['HOME']), 'vosk/models'))
|
||||
modelPath = os.path.join(modelBase, sys.argv[2] if len(sys.argv) > 2 else 'daanzu')
|
||||
if not os.path.exists(modelPath):
|
||||
print (f"Please download a model from https://alphacephei.com/vosk/models and unpack it to {modelPath}.", file=sys.stderr)
|
||||
exit (1)
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print (f"Usage: {sys.argv[0]} <audio> [model]", file=sys.stderr)
|
||||
exit (1)
|
||||
|
||||
sample_rate=16000
|
||||
model = Model(modelPath)
|
||||
rec = KaldiRecognizer(model, sample_rate)
|
||||
kaldi = KaldiRecognizer(model, sample_rate)
|
||||
|
||||
process = subprocess.Popen(['ffmpeg', '-loglevel', 'quiet', '-i',
|
||||
sys.argv[1],
|
||||
|
@ -36,7 +40,7 @@ while True:
|
|||
data = process.stdout.read(4000)
|
||||
if len(data) == 0:
|
||||
break
|
||||
if rec.AcceptWaveform(data):
|
||||
print(getText(rec.Result()))
|
||||
if kaldi.AcceptWaveform(data):
|
||||
print(getText(kaldi.Result()))
|
||||
|
||||
print(getText(rec.FinalResult()))
|
||||
print(getText(kaldi.FinalResult()))
|
||||
|
|
6
.zshenv
6
.zshenv
|
@ -13,6 +13,8 @@ export XDG_CONFIG_HOME="$HOME/.config"
|
|||
export JOURNAL="$(eval "dirname $(grep -1 journals $XDG_CONFIG_HOME/jrnl/jrnl.yaml | tail -1 | cut -d':' -f2-)" ||
|
||||
echo "$DATA/2-box/journal")"
|
||||
export INSTALEE_HOME="$DATA/1-projects/1-personal/instalee"
|
||||
test -d "/mnt/data/projects/vosk/models" &&
|
||||
export VOSK_MODELS="/mnt/data/projects/vosk/models"
|
||||
# adjust programs to use xdg
|
||||
export MNT=/run/media/$USER
|
||||
export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority
|
||||
|
@ -33,8 +35,8 @@ export WINEPREFIX="$XDG_DATA_HOME"/wine
|
|||
export GOPATH="$XDG_STATE_HOME"/go
|
||||
export KREW_ROOT="$XDG_DATA_HOME"/krew
|
||||
|
||||
export CARGO_HOME="$XDG_DATA_HOME"/cargo
|
||||
export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
|
||||
export CARGO_HOME="$XDG_STATE_HOME"/cargo
|
||||
export RUSTUP_HOME="$XDG_STATE_HOME"/rustup
|
||||
|
||||
export NVM_DIR="$XDG_DATA_HOME"/nvm
|
||||
export N_PREFIX="$XDG_STATE_HOME"/n
|
||||
|
|
Loading…
Reference in New Issue