def add_stt_span_attributes(
    span: "Span",
    service_name: str,
    model: str,
    operation_name: str = "stt",
    transcript: Optional[str] = None,
    is_final: Optional[bool] = None,
    language: Optional[str] = None,
    settings: Optional[Dict[str, Any]] = None,
    vad_enabled: bool = False,
    ttfb: Optional[float] = None,
    **kwargs,
) -> None:
    """Add STT-specific attributes to a span.

    Args:
        span: The span to add attributes to
        service_name: Name of the STT service (e.g., "deepgram")
        model: Model name/identifier
        operation_name: Name of the operation (default: "stt")
        transcript: The transcribed text
        is_final: Whether this is a final transcript
        language: Detected or configured language
        settings: Service configuration settings
        vad_enabled: Whether voice activity detection is enabled
        ttfb: Time to first byte in seconds
        **kwargs: Additional attributes to add
    """
    # Add standard attributes
    span.set_attribute("gen_ai.system", service_name.replace("STTService", "").lower())
    span.set_attribute("gen_ai.request.model", model)
    span.set_attribute("gen_ai.operation.name", operation_name)
    span.set_attribute("vad_enabled", vad_enabled)

    # Add optional attributes
    if transcript:
        span.set_attribute("transcript", transcript)

    if is_final is not None:
        span.set_attribute("is_final", is_final)

    if language:
        span.set_attribute("language", language)

    if ttfb is not None:
        span.set_attribute("metrics.ttfb", ttfb)

    # Add settings if provided
    if settings:
        for key, value in settings.items():
            if isinstance(value, (str, int, float, bool)):
                span.set_attribute(f"settings.{key}", value)

    # Add any additional keyword arguments as attributes
    for key, value in kwargs.items():
        if isinstance(value, (str, int, float, bool)):
            span.set_attribute(key, value)
Add STT-specific attributes to a span.

    Args:
        span: The span to add attributes to
        service_name: Name of the STT service (e.g., "deepgram")
        model: Model name/identifier
        operation_name: Name of the operation (default: "stt")
        transcript: The transcribed text
        is_final: Whether this is a final transcript
        language: Detected or configured language
        settings: Service configuration settings
        vad_enabled: Whether voice activity detection is enabled
        ttfb: Time to first byte in seconds
        **kwargs: Additional attributes to add
    
src/pipecat/utils/tracing/service_attributes.py