mirror of
https://github.com/leon-ai/leon.git
synced 2024-08-17 06:00:33 +03:00
feat: kick off ASR engine support for Apple Silicon
This commit is contained in:
parent
04c3e88224
commit
582b2aa572
2
.gitignore
vendored
2
.gitignore
vendored
@ -22,8 +22,6 @@ debug.log
|
||||
.env
|
||||
.last-skill-npm-install
|
||||
leon.json
|
||||
bridges/python/src/Pipfile.lock
|
||||
tcp_server/src/Pipfile.lock
|
||||
tcp_server/src/lib/tts/models/*.pth
|
||||
tcp_server/src/lib/tts/models/**/*.bin
|
||||
tcp_server/src/lib/tts/models/**/*.json
|
||||
|
@ -204,7 +204,7 @@ SPACY_MODELS.set('fr', {
|
||||
}
|
||||
}
|
||||
const installPythonPackages = async () => {
|
||||
LogHelper.info(`Installing Python packages from ${pipfilePath}.lock...`)
|
||||
LogHelper.info(`Installing Python packages from ${pipfilePath}...`)
|
||||
|
||||
// Delete .venv directory to reset the development environment
|
||||
if (hasDotVenv) {
|
||||
@ -214,7 +214,7 @@ SPACY_MODELS.set('fr', {
|
||||
}
|
||||
|
||||
try {
|
||||
await command('pipenv install --verbose --site-packages', {
|
||||
await command('pipenv install --verbose --skip-lock', {
|
||||
shell: true,
|
||||
stdio: 'inherit'
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import numpy as np
|
||||
from faster_whisper import WhisperModel
|
||||
|
||||
from ..constants import ASR_MODEL_PATH_FOR_GPU, ASR_MODEL_PATH_FOR_CPU
|
||||
from ..utils import ThrottledCallback
|
||||
from ..utils import ThrottledCallback, is_macos
|
||||
|
||||
|
||||
class ASR:
|
||||
@ -20,21 +20,21 @@ class ASR:
|
||||
self.log('Loading model...')
|
||||
|
||||
if device == 'auto':
|
||||
device = 'cpu'
|
||||
|
||||
if torch.cuda.is_available(): device = 'cuda'
|
||||
else: self.log('GPU not available. CUDA is not installed?')
|
||||
|
||||
if torch.backends.mps.is_available(): device = 'mps'
|
||||
if 'cuda' in device:
|
||||
assert torch.cuda.is_available()
|
||||
|
||||
self.log(f'Device: {device}')
|
||||
|
||||
compute_type = "float16"
|
||||
compute_type = 'float16'
|
||||
if is_macos():
|
||||
compute_type = 'int8_float32'
|
||||
|
||||
if device == 'cpu':
|
||||
compute_type = "int8_float32"
|
||||
compute_type = 'int8_float32'
|
||||
|
||||
self.compute_type = compute_type
|
||||
|
||||
@ -169,7 +169,7 @@ class ASR:
|
||||
self.log("Recording...")
|
||||
frames = []
|
||||
while True:
|
||||
data = self.stream.read(self.chunk)
|
||||
data = self.stream.read(self.chunk, exception_on_overflow=False)
|
||||
data_np = np.frombuffer(data, dtype=np.int16)
|
||||
|
||||
# Check if the audio data contains any non-finite values
|
||||
|
@ -1,4 +1,5 @@
|
||||
import time
|
||||
import sys
|
||||
|
||||
|
||||
class ThrottledCallback:
|
||||
@ -12,3 +13,15 @@ class ThrottledCallback:
|
||||
if current_time - self.last_call > self.min_interval:
|
||||
self.callback(*args, **kwargs)
|
||||
self.last_call = current_time
|
||||
|
||||
|
||||
def is_macos():
|
||||
return sys.platform == 'darwin'
|
||||
|
||||
|
||||
def is_windows():
|
||||
return sys.platform == 'win32'
|
||||
|
||||
|
||||
def is_linux():
|
||||
return sys.platform == 'linux'
|
||||
|
Loading…
Reference in New Issue
Block a user