even the parameters are fixed, keep aic ready for processing.
This commit is contained in:
@@ -18,7 +18,14 @@ import os
|
||||
from typing import List, Optional
|
||||
|
||||
import numpy as np
|
||||
from aic_sdk import Model, ProcessorAsync, ProcessorConfig, ProcessorParameter, set_sdk_id
|
||||
from aic_sdk import (
|
||||
Model,
|
||||
ParameterFixedError,
|
||||
ProcessorAsync,
|
||||
ProcessorConfig,
|
||||
ProcessorParameter,
|
||||
set_sdk_id,
|
||||
)
|
||||
from loguru import logger
|
||||
|
||||
from pipecat.audio.filters.base_audio_filter import BaseAudioFilter
|
||||
@@ -156,7 +163,6 @@ class AICFilter(BaseAudioFilter):
|
||||
"""
|
||||
self._sample_rate = sample_rate
|
||||
|
||||
try:
|
||||
# Load or download model
|
||||
if self._model_path:
|
||||
logger.debug(f"Loading AIC model from: {self._model_path}")
|
||||
@@ -182,20 +188,27 @@ class AICFilter(BaseAudioFilter):
|
||||
)
|
||||
|
||||
# Create async processor
|
||||
try:
|
||||
self._processor = ProcessorAsync(self._model, self._license_key, config)
|
||||
self._aic_ready = True
|
||||
except Exception as e: # noqa: BLE001 - surfacing SDK initialization errors
|
||||
logger.error(f"AIC model initialization failed: {e}")
|
||||
self._aic_ready = False
|
||||
|
||||
# Get contexts for parameter control and VAD
|
||||
self._processor_ctx = self._processor.get_processor_context()
|
||||
self._vad_ctx = self._processor.get_vad_context()
|
||||
|
||||
try:
|
||||
# Apply initial parameters
|
||||
if self._enhancement_level is not None:
|
||||
level = self._enhancement_level if self._enabled else 0.0
|
||||
self._processor_ctx.set_parameter(ProcessorParameter.EnhancementLevel, level)
|
||||
|
||||
if self._voice_gain is not None:
|
||||
self._processor_ctx.set_parameter(ProcessorParameter.VoiceGain, self._voice_gain)
|
||||
|
||||
self._aic_ready = True
|
||||
except ParameterFixedError as e:
|
||||
logger.error(f"AIC parameter update failed: {e}")
|
||||
|
||||
# Log processor information
|
||||
logger.debug(f"ai-coustics filter started:")
|
||||
@@ -208,9 +221,6 @@ class AICFilter(BaseAudioFilter):
|
||||
f" Output delay: {self._processor_ctx.get_output_delay()} samples "
|
||||
f"({self._processor_ctx.get_output_delay() / self._sample_rate * 1000:.2f}ms)"
|
||||
)
|
||||
except Exception as e: # noqa: BLE001 - surfacing SDK initialization errors
|
||||
logger.error(f"AIC model initialization failed: {e}")
|
||||
self._aic_ready = False
|
||||
|
||||
async def stop(self):
|
||||
"""Clean up the AIC processor when stopping.
|
||||
|
||||
Reference in New Issue
Block a user