Smart Turn v3.1
This commit is contained in:
@@ -159,7 +159,7 @@ where = ["src"]
|
|||||||
"src/pipecat/audio/dtmf/dtmf-star.wav",
|
"src/pipecat/audio/dtmf/dtmf-star.wav",
|
||||||
]
|
]
|
||||||
"pipecat.services.aws_nova_sonic" = ["src/pipecat/services/aws_nova_sonic/ready.wav"]
|
"pipecat.services.aws_nova_sonic" = ["src/pipecat/services/aws_nova_sonic/ready.wav"]
|
||||||
"pipecat.audio.turn.smart_turn.data" = ["src/pipecat/audio/turn/smart_turn/data/smart-turn-v3.0.onnx"]
|
"pipecat.audio.turn.smart_turn.data" = ["src/pipecat/audio/turn/smart_turn/data/smart-turn-v3.1-cpu.onnx"]
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
addopts = "--verbose"
|
addopts = "--verbose"
|
||||||
|
|||||||
Binary file not shown.
@@ -42,17 +42,15 @@ class LocalSmartTurnAnalyzerV3(BaseSmartTurn):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
smart_turn_model_path: Path to the ONNX model file. If this is not
|
smart_turn_model_path: Path to the ONNX model file. If this is not
|
||||||
set, the bundled smart-turn-v3.0 model will be used.
|
set, the bundled smart-turn-v3.1-cpu model will be used.
|
||||||
cpu_count: The number of CPUs to use for inference. Defaults to 1.
|
cpu_count: The number of CPUs to use for inference. Defaults to 1.
|
||||||
**kwargs: Additional arguments passed to BaseSmartTurn.
|
**kwargs: Additional arguments passed to BaseSmartTurn.
|
||||||
"""
|
"""
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
logger.debug("Loading Local Smart Turn v3 model...")
|
|
||||||
|
|
||||||
if not smart_turn_model_path:
|
if not smart_turn_model_path:
|
||||||
# Load bundled model
|
# Load bundled model
|
||||||
model_name = "smart-turn-v3.0.onnx"
|
model_name = "smart-turn-v3.1-cpu.onnx"
|
||||||
package_path = "pipecat.audio.turn.smart_turn.data"
|
package_path = "pipecat.audio.turn.smart_turn.data"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -70,6 +68,8 @@ class LocalSmartTurnAnalyzerV3(BaseSmartTurn):
|
|||||||
impresources.files(package_path).joinpath(model_name)
|
impresources.files(package_path).joinpath(model_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger.debug(f"Loading Local Smart Turn v3.x model from {smart_turn_model_path}...")
|
||||||
|
|
||||||
so = ort.SessionOptions()
|
so = ort.SessionOptions()
|
||||||
so.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
|
so.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
|
||||||
so.inter_op_num_threads = 1
|
so.inter_op_num_threads = 1
|
||||||
@@ -79,7 +79,7 @@ class LocalSmartTurnAnalyzerV3(BaseSmartTurn):
|
|||||||
self._feature_extractor = WhisperFeatureExtractor(chunk_length=8)
|
self._feature_extractor = WhisperFeatureExtractor(chunk_length=8)
|
||||||
self._session = ort.InferenceSession(smart_turn_model_path, sess_options=so)
|
self._session = ort.InferenceSession(smart_turn_model_path, sess_options=so)
|
||||||
|
|
||||||
logger.debug("Loaded Local Smart Turn v3")
|
logger.debug("Loaded Local Smart Turn v3.x")
|
||||||
|
|
||||||
def _predict_endpoint(self, audio_array: np.ndarray) -> Dict[str, Any]:
|
def _predict_endpoint(self, audio_array: np.ndarray) -> Dict[str, Any]:
|
||||||
"""Predict end-of-turn using local ONNX model."""
|
"""Predict end-of-turn using local ONNX model."""
|
||||||
|
|||||||
Reference in New Issue
Block a user