Skip to content

Incorrect sample width in 24-bit audio conversion path #359

@coderabbitai

Description

@coderabbitai

Description

In ovos_plugin_manager/utils/audio.py, the get_raw_data method has a potential bug in the 24-bit audio conversion path.

When converting to 24-bit audio and the runtime supports 24-bit audio (Python 3.4+), the code at lines 228-230 attempts to convert from self.sample_width to convert_width. However, raw_data has already been converted to 32-bit (4 bytes) at lines 213-215. This causes audioop.lin2lin to interpret the data with the wrong source width.

The issue occurs in the else branch (lines 227-230) after the audioop.bias check, where it should convert from width 4 (not self.sample_width) since the data was already converted to 32-bit.

Context

This code was ported from the upstream speech_recognition library in PR #357.

Related PR: #357
Original review comment: #357 (comment)

Reported by: @coderabbitai

Metadata

Metadata

Assignees

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