Skip to content

Error when normalizing stereo sound in groq_client.py #21

@shravankshenoy

Description

@shravankshenoy

I think there is a minor bug in the code snippet below

https://github.com/PeoplePlusAI/sunva/blob/a32a67704d3a4750fe790ce27736015249614baa/backend/core/stt/groq_client.py#L75C8-L87

For stereo sound, when converting to mono, the datatype of audio_data becomes float64 because for np.mean the default return type for integer inputs is float64. On passing this float variable to np.iinfo, we will get an error as the iinfo function works only for integer types

Potential solution

  1. Specify the output datatype as np.int16 in np.mean
    audio_data.mean(axis=1, dtype=np.int16)
  2. Use np.finfo for stereo sounds

I think the first approach is better, but would love to know others thoughts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions