Skip to content

Commit

Permalink
Merge pull request #39 from wst24365888/dev
Browse files Browse the repository at this point in the history
chore: remove unused dependency
  • Loading branch information
wst24365888 authored Jun 7, 2022
2 parents 2789641 + 3a57331 commit 4ff6819
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 72 deletions.
56 changes: 2 additions & 54 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "voice-presentation-control"
version = "1.0.1"
version = "1.0.2"
description = "voice-presentation-control is a tool that allows you to control your presentation using voice when you don't have a presentation pen or when it's inconvinient to use the keyboard."
authors = ["Xyphuz <[email protected]>"]
readme = "README.md"
Expand All @@ -14,14 +14,12 @@ include = [
]

[tool.poetry.dependencies]
python = ">=3.9,<3.11"
python = "^3.9"
PyAudio = "^0.2.11"
typer = "^0.4.1"
PyAutoGUI = "^0.9.53"
numpy = "^1.22.3"
vosk = "^0.3.32"
scipy = "^1.8.1"
logmmse = "^1.5"

[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
Expand Down
2 changes: 1 addition & 1 deletion voice_presentation_control/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__app_name__ = "voice_presentation_control"
__version__ = "1.0.1"
__version__ = "1.0.2"
27 changes: 14 additions & 13 deletions voice_presentation_control/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from queue import Queue
from typing import List

import logmmse
import numpy as np
import pyaudio

Expand Down Expand Up @@ -162,11 +161,6 @@ def volume_process(self, wave_values: np.ndarray) -> array:

return wave_values_arr

def denoise(self, wave_values: np.ndarray) -> np.ndarray:
wave_values = logmmse.logmmse(data=wave_values, sampling_rate=self.rate, noise_threshold=0.15, window_size=0)

return wave_values

def freqs_process(self, fft_wave: np.ndarray) -> np.ndarray:
sample_num = len(fft_wave)

Expand All @@ -176,14 +170,22 @@ def freqs_process(self, fft_wave: np.ndarray) -> np.ndarray:

# filter
fft_filter = vib_fft.copy()
noise_indices = np.where((abs(fft_freqs) > 8000) & (abs(fft_freqs) < 10000))
fft_filter[noise_indices] = fft_filter[noise_indices] * 0.5 # .1
fft_filter = fft_filter / 10

noise_indices = np.where(((abs(fft_freqs) >= 100) & (abs(fft_freqs) < 200))) # n
fft_filter[noise_indices] = fft_filter[noise_indices] * 10

noise_indices = np.where(((abs(fft_freqs) >= 1500) & (abs(fft_freqs) < 2000))) # p
fft_filter[noise_indices] = fft_filter[noise_indices] * 2

noise_indices = np.where(((abs(fft_freqs) >= 3000) & (abs(fft_freqs) < 3500))) # n
fft_filter[noise_indices] = fft_filter[noise_indices] * 5

noise_indices = np.where(abs(fft_freqs) >= 10000)
fft_filter[noise_indices] = fft_filter[noise_indices] * 0.1 # .05
noise_indices = np.where(((abs(fft_freqs) >= 5000) & (abs(fft_freqs) < 8000))) # x
fft_filter[noise_indices] = fft_filter[noise_indices]

noise_indices = np.where(abs(fft_freqs) >= 15000)
fft_filter[noise_indices] = fft_filter[noise_indices] * 0
noise_indices = np.where((abs(fft_freqs) > 8000))
fft_filter[noise_indices] = fft_filter[noise_indices] * 0 # .1

filter_wave_ifft = np.fft.ifft(fft_filter).real

Expand All @@ -193,7 +195,6 @@ def audio_preprocess(self, record_frames: List[bytes]) -> bytes:
wave_values = np.array(array("h", b"".join(record_frames)))

wave_values = self.freqs_process(wave_values)
# wave_values = self.denoise(wave_values)
wave_values_arr = self.volume_process(wave_values)

return wave_values_arr.tobytes()

0 comments on commit 4ff6819

Please sign in to comment.