This commit is contained in:
pali112 2025-01-18 13:56:36 +01:00
commit 2c49d6647d
22 changed files with 754 additions and 0 deletions

142
#.gitignore# Normal file
View File

@ -0,0 +1,142 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
Pipfile.lock
# poetry
poetry.lock
# pdm
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582
__pypackages__/
# Celery
celerybeat-schedule
celerybeat.pid
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre
.pyre/
# pytype
.pytype/
# Cython debug symbols
cython_debug/
# Ruff
.ruff_cache/
# PyPI configuration file
.pypirc

142
.gitignore vendored Normal file
View File

@ -0,0 +1,142 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
Pipfile.lock
# poetry
poetry.lock
# pdm
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582
__pypackages__/
# Celery
celerybeat-schedule
celerybeat.pid
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre
.pyre/
# pytype
.pytype/
# Cython debug symbols
cython_debug/
# Ruff
.ruff_cache/
# PyPI configuration file
.pypirc

0
.gitignore~ Normal file
View File

1
README.md Normal file
View File

@ -0,0 +1 @@
Vosk

0
README.md~ Normal file
View File

176
gitignoreaa Normal file
View File

@ -0,0 +1,176 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
vosk
sounddevice
pyperclip
pyautogui

View File

@ -0,0 +1,7 @@
Small Polish model for Vosk
WER
%WER 18.36 [ 10713 / 58340, 1355 ins, 1588 del, 7770 sub ] exp/chain/tdnn/decode_test_cv_look_fast/wer_10_0.0
%WER 16.88 [ 2876 / 17034, 519 ins, 247 del, 2110 sub ] exp/chain/tdnn/decode_test_mls_look_fast/wer_8_0.0
%WER 11.55 [ 4153 / 35963, 979 ins, 1079 del, 2095 sub ] exp/chain/tdnn/decode_test_vox_look_fast/wer_9_0.0

Binary file not shown.

View File

@ -0,0 +1,8 @@
--use-energy=false
--sample-frequency=16000
--num-mel-bins=40
--num-ceps=40
--low-freq=40
--high-freq=-200
--allow-upsample=true
--allow-downsample=true

View File

@ -0,0 +1,10 @@
--min-active=200
--max-active=3000
--beam=10.0
--lattice-beam=2.0
--acoustic-scale=1.0
--frame-subsampling-factor=3
--endpoint.silence-phones=1:2:3:4:5:6:7:8:9:10
--endpoint.rule2.min-trailing-silence=0.5
--endpoint.rule3.min-trailing-silence=0.75
--endpoint.rule4.min-trailing-silence=1.0

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
10023
10024
10025
10026
10027
10028
10029

View File

@ -0,0 +1,154 @@
1 nonword
2 begin
3 end
4 internal
5 singleton
6 nonword
7 begin
8 end
9 internal
10 singleton
11 begin
12 end
13 internal
14 singleton
15 begin
16 end
17 internal
18 singleton
19 begin
20 end
21 internal
22 singleton
23 begin
24 end
25 internal
26 singleton
27 begin
28 end
29 internal
30 singleton
31 begin
32 end
33 internal
34 singleton
35 begin
36 end
37 internal
38 singleton
39 begin
40 end
41 internal
42 singleton
43 begin
44 end
45 internal
46 singleton
47 begin
48 end
49 internal
50 singleton
51 begin
52 end
53 internal
54 singleton
55 begin
56 end
57 internal
58 singleton
59 begin
60 end
61 internal
62 singleton
63 begin
64 end
65 internal
66 singleton
67 begin
68 end
69 internal
70 singleton
71 begin
72 end
73 internal
74 singleton
75 begin
76 end
77 internal
78 singleton
79 begin
80 end
81 internal
82 singleton
83 begin
84 end
85 internal
86 singleton
87 begin
88 end
89 internal
90 singleton
91 begin
92 end
93 internal
94 singleton
95 begin
96 end
97 internal
98 singleton
99 begin
100 end
101 internal
102 singleton
103 begin
104 end
105 internal
106 singleton
107 begin
108 end
109 internal
110 singleton
111 begin
112 end
113 internal
114 singleton
115 begin
116 end
117 internal
118 singleton
119 begin
120 end
121 internal
122 singleton
123 begin
124 end
125 internal
126 singleton
127 begin
128 end
129 internal
130 singleton
131 begin
132 end
133 internal
134 singleton
135 begin
136 end
137 internal
138 singleton
139 begin
140 end
141 internal
142 singleton
143 begin
144 end
145 internal
146 singleton
147 begin
148 end
149 internal
150 singleton
151 begin
152 end
153 internal
154 singleton

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,3 @@
[
2.332269e+10 -1.591427e+09 -2.386425e+09 2.567631e+09 -4.278615e+09 -3.173767e+09 -4.979451e+09 -9.337341e+08 -4.065907e+09 4.164767e+08 -2.657036e+09 4.584832e+08 -2.262707e+09 3.725578e+08 -1.617336e+09 -2.422944e+08 -1.090407e+09 2.546636e+07 -6.561927e+08 9189418 -3.021461e+08 3653924 -6.909018e+07 1145230 1.260959e+08 943479.1 2.129454e+08 -2.020883e+07 2.41263e+08 -6.784136e+07 1.749356e+08 -7.806565e+07 1.935013e+08 5642923 1.609053e+08 -7.734538e+07 2.77092e+07 -5.172138e+07 -49565.82 -8910038 2.324062e+08
2.412661e+12 1.583657e+11 1.264655e+11 1.656757e+11 2.058363e+11 1.898538e+11 2.641202e+11 1.389405e+11 2.097279e+11 1.192258e+11 1.407295e+11 1.103615e+11 1.114059e+11 7.456539e+10 6.95057e+10 4.503035e+10 4.047014e+10 2.547089e+10 1.794963e+10 9.693594e+09 5.137935e+09 1.659491e+09 2.522086e+08 6.66451e+07 8.935486e+08 2.06827e+09 3.710687e+09 4.865626e+09 6.180052e+09 6.763839e+09 7.517699e+09 7.911833e+09 8.443634e+09 7.663356e+09 6.383157e+09 5.242324e+09 4.541044e+09 3.729303e+09 2.948872e+09 1.861148e+09 0 ]

View File

@ -0,0 +1,2 @@
--left-context=3
--right-context=3

98
voskpl.py Executable file
View File

@ -0,0 +1,98 @@
from vosk import Model, KaldiRecognizer
import sounddevice as sd
import json
import pyperclip # Biblioteka do obsługi schowka
import pyautogui
import sys
import tkinter as tk
from threading import Thread
# Ścieżka do modelu
model_path = "/home/pali112/vosk/vosk-model-small-pl-0.22"
model = Model(model_path)
recognizer = KaldiRecognizer(model, 16000)
listening = False # Flaga stanu nasłuchiwania
# Funkcja obsługi danych audio
def callback(indata, frames, time, status):
if status:
print(f"Status: {status}", file=sys.stderr)
# Konwersja danych na `bytes`
data = bytes(indata)
if recognizer.AcceptWaveform(data):
result = json.loads(recognizer.Result())
text = result.get("text", "")
if text:
print(f"Rozpoznano: {text}")
insert_text_with_clipboard(text)
# Funkcja kopiowania do schowka i wklejania
def insert_text_with_clipboard(text):
try:
pyperclip.copy(text) # Kopiowanie tekstu do schowka
pyautogui.hotkey('ctrl', 'v') # Symulacja wklejania
pyautogui.press('space') # Dodanie spacji (opcjonalne)
except Exception as e:
print(f"Błąd podczas wklejania tekstu: {e}", file=sys.stderr)
# Funkcja nasłuchiwania i rozpoznawania mowy
def listen_and_type():
global listening
print("Słucham... (naciśnij Stop, aby zatrzymać)")
try:
with sd.RawInputStream(samplerate=16000, blocksize=8000, dtype='int16',
channels=1, callback=callback):
while listening:
pass # Nasłuchiwanie trwa w pętli
except Exception as e:
print(f"Błąd podczas nasłuchiwania: {e}", file=sys.stderr)
# Funkcje sterujące GUI
def toggle_listening():
global listening
if listening:
listening = False
update_button_state()
print("Nasłuchiwanie zatrzymane.")
else:
listening = True
update_button_state()
thread = Thread(target=listen_and_type)
thread.daemon = True
thread.start()
def update_button_state():
if listening:
toggle_button.config(text="Stop", bg="red", fg="white")
else:
toggle_button.config(text="Start", bg="lightgrey", fg="black")
# Funkcja obsługi skrótu klawiszowego
def handle_shortcut(event):
if event.keysym == 'F1': # F1 jako skrót klawiszowy
toggle_listening()
# Tworzenie GUI
def create_gui():
global toggle_button
root = tk.Tk()
root.title("Vosk Rozpoznawanie Mowy")
root.geometry("300x150")
toggle_button = tk.Button(root, text="Start", command=toggle_listening, width=15, bg="lightgrey", fg="black")
toggle_button.pack(pady=10)
exit_button = tk.Button(root, text="Wyjście", command=root.destroy, width=15)
exit_button.pack(pady=10)
# Dodanie skrótu klawiszowego
root.bind("<F1>", handle_shortcut)
root.mainloop()
# Uruchomienie GUI
if __name__ == "__main__":
create_gui()