Repository navigation
Mkulakow/audio format fix - #4637
Open
michalkulakowski wants to merge 1 commit into
Open
michalkulakowski wants to merge 1 commit into
michalkulakowski wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The implementation has portability, undefined-behavior, disabled-build, and oversized-test defects.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Updates text-to-speech responses to honor WAV/PCM formats and return matching content types.
Changes:
- Converts generated audio to PCM16 WAV or raw PCM16.
- Rejects unsupported response formats.
- Adds custom HTTP content types and tests.
| File | Description |
|---|---|
src/audio/audio_utils.cpp |
Implements PCM16 conversion and output. |
src/audio/audio_utils.hpp |
Declares audio format utilities. |
src/audio/text_to_speech/t2s_calculator.cc |
Selects and validates response formats. |
src/http_rest_api_handler.cpp |
Assigns audio response content types. |
src/http_rest_api_handler.hpp |
Adds custom content-type support. |
src/http_server.cpp |
Emits custom HTTP content types. |
src/llm/omni_model/legacy/servable.cpp |
Uses the updated WAV writer. |
src/test/audio/audio_utils_test.cpp |
Tests PCM16 output and limits. |
src/test/audio/text2speech_test.cpp |
Tests formats and content types. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
michalkulakowski
force-pushed
the
mkulakow/audio_format_fix
branch
from
October 13, 2026 09:39
1fecd87 to
3646061
Compare
michalkulakowski
force-pushed
the
mkulakow/audio_format_fix
branch
from
October 13, 2026 14:47
3646061 to
9a6048e
Compare
Comment on lines
+337
to
+343
| *ppData = std::malloc(pDataSize); | ||
| if (*ppData == nullptr && pDataSize > 0) { | ||
| throw std::runtime_error("Failed to allocate raw PCM output buffer"); | ||
| } | ||
| auto pcm16 = convertWaveformToPcm16(speechSize, waveformPtr); | ||
| std::memcpy(*ppData, pcm16.data(), pDataSize); | ||
| } |
|
|
||
| void prepareAudioOutput(void** ppData, size_t& pDataSize, uint32_t sampleRate, size_t speechSize, const float* waveformPtr); | ||
|
|
||
| void prepareRawPcm16LEOutput(void** ppData, size_t& pDataSize, size_t speechSize, const float* waveformPtr); |
Comment on lines
+160
to
+168
| auto responseFormat = ovms::audio_utils::TextToSpeechResponseFormat::WAV; | ||
| auto responseFormatIt = payload.parsedJson->FindMember("response_format"); | ||
| if (responseFormatIt != payload.parsedJson->MemberEnd()) { | ||
| if (!responseFormatIt->value.IsString()) { | ||
| return absl::InvalidArgumentError("response_format field is not a string"); | ||
| } | ||
| auto requestedFormat = ovms::audio_utils::tryParseTextToSpeechResponseFormat(responseFormatIt->value.GetString()); | ||
| if (!requestedFormat.has_value()) { | ||
| return absl::InvalidArgumentError("Unsupported response_format. Supported formats are wav and pcm"); |
| } | ||
| output = std::make_unique<std::string>(reinterpret_cast<char*>(ppData), pDataSize); | ||
| drwav_free(ppData, NULL); | ||
| std::free(ppData); |
Comment on lines
+88
to
+89
| EXPECT_EQ(responseComponents.contentType, ContentType::CUSTOM); | ||
| EXPECT_EQ(responseComponents.customContentType, "audio/wav"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



🛠 Summary
#4613
🧪 Checklist
``