Skip to content

[Bug]: ValidationError on speaker_confidence in ListenV1Response after upgrading to v5 #615

@petersli

Description

@petersli

Summary

ValidationError: Input should be a valid integer, got a number with a fractional part

What happened?

I saw a ValidatorError here:

12 validation errors for union[ListenV1Response,ListenV1AcceptedResponse]
ListenV1Response.results.utterances.0.words.0.speaker_confidence
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=0.74699605, input_type=float]
    For further information visit https://errors.pydantic.dev/2.11/v/int_from_float
ListenV1Response.results.utterances.0.words.1.speaker_confidence
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=0.74699605, input_type=float]
    For further information visit https://errors.pydantic.dev/2.11/v/int_from_float
ListenV1Response.results.utterances.0.words.2.speaker_confidence
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=0.74699605, input_type=float]
    For further information visit https://errors.pydantic.dev/2.11/v/int_from_float
ListenV1Response.results.utterances.0.words.3.speaker_confidence
  Input should be a valid inte...

The model has speaker_confidence defined as an int, but clearly it's sometimes a float.

I would expect this not to crash.

Steps to reproduce

  1. Install deepgram sdk 5.1.0
  2. Observe that occasionally, you will hit a validation error (depending on how confident you sound, I guess)

Minimal code sample

from deepgram import DeepgramClient
deepgram = DeepgramClient(api_key=settings.DEEPGRAM_API_KEY)
response = deepgram.listen.v1.media.transcribe_file(
            request=audio_data,
            model="nova-3",
            smart_format=True,
            utterances=True,
            punctuate=True,
            diarize=True,
        )

Logs / traceback

12 validation errors for union[ListenV1Response,ListenV1AcceptedResponse]
ListenV1Response.results.utterances.0.words.0.speaker_confidence
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=0.74699605, input_type=float]
    For further information visit https://errors.pydantic.dev/2.11/v/int_from_float
ListenV1Response.results.utterances.0.words.1.speaker_confidence
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=0.74699605, input_type=float]
    For further information visit https://errors.pydantic.dev/2.11/v/int_from_float
ListenV1Response.results.utterances.0.words.2.speaker_confidence
  Input should be a valid integer, got a number with a fractional part [type=int_from_float, input_value=0.74699605, input_type=float]
    For further information visit https://errors.pydantic.dev/2.11/v/int_from_float
ListenV1Response.results.utterances.0.words.3.speaker_confidence
  Input should be a valid inte...

Transport

HTTP

API endpoint / path

/v1/listen/

Model(s) used

nova-3

How often?

Sometimes

Is this a regression?

  • Yes, it worked in an earlier version

Last working SDK version (if known)

4.8.1

SDK version

5.1.0

Python version

3.10.18

Install method

None

OS

macOS (Apple Silicon), Linux (x86_64), Linux (arm64)

Environment details


Link to minimal repro (optional)

No response

Session ID (optional)

No response

Project ID (optional)

No response

Request ID (optional)

No response

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions