Merge pull request #2536 from gladiaio/PLA-38-missing-config-parameters

Gladia - add missing config parameters
This commit is contained in:
Mark Backman
2025-09-01 12:42:10 -07:00
committed by GitHub
3 changed files with 15 additions and 3 deletions

View File

@@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
sending it through the transport. This makes sending DTMF generic across all
output transports.
- Added new config parameters to `GladiaSTTService`.
- PreProcessingConfig > `audio_enhancer` to enhance audio quality.
- CustomVocabularyItem > `pronunciations` and `language` to specify special pronunciations and in which language it will be pronounced.
## Changed
- `pipecat.frames.frames.KeypadEntry` is deprecated and has been moved to

View File

@@ -29,9 +29,11 @@ class PreProcessingConfig(BaseModel):
"""Configuration for audio pre-processing options.
Parameters:
audio_enhancer: Apply pre-processing to the audio stream to enhance quality
speech_threshold: Sensitivity for speech detection (0-1)
"""
audio_enhancer: Optional[bool] = None
speech_threshold: Optional[float] = None
@@ -41,10 +43,14 @@ class CustomVocabularyItem(BaseModel):
Parameters:
value: The vocabulary word or phrase
intensity: The bias intensity for this vocabulary item (0-1)
pronunciations: The pronunciations used in the transcription.
language: Specify the language in which it will be pronounced when sound comparison occurs. Default to transcription language.
"""
value: str
intensity: float
pronunciations: Optional[List[str]] = None
language: Optional[str] = None
class CustomVocabularyConfig(BaseModel):
@@ -170,7 +176,7 @@ class GladiaInputParams(BaseModel):
channels: Optional[int] = 1
custom_metadata: Optional[Dict[str, Any]] = None
endpointing: Optional[float] = None
maximum_duration_without_endpointing: Optional[int] = 10
maximum_duration_without_endpointing: Optional[int] = 5
language: Optional[Language] = None # Deprecated
language_config: Optional[LanguageConfig] = None
pre_processing: Optional[PreProcessingConfig] = None

View File

@@ -18,6 +18,7 @@ from typing import Any, AsyncGenerator, Dict, Literal, Optional
import aiohttp
from loguru import logger
from pipecat import __version__ as pipecat_version
from pipecat.frames.frames import (
CancelFrame,
EndFrame,
@@ -303,8 +304,8 @@ class GladiaSTTService(STTService):
}
# Add custom_metadata if provided
if self._params.custom_metadata:
settings["custom_metadata"] = self._params.custom_metadata
settings["custom_metadata"] = dict(self._params.custom_metadata or {})
settings["custom_metadata"]["pipecat"] = pipecat_version
# Add endpointing parameters if provided
if self._params.endpointing is not None:
@@ -430,6 +431,7 @@ class GladiaSTTService(STTService):
response = await self._setup_gladia(settings)
self._session_url = response["url"]
self._reconnection_attempts = 0
logger.info(f"Session URL : {self._session_url}")
# Connect with automatic reconnection
async with websocket_connect(self._session_url) as websocket: