← Back to Pull requests

fix(tts): don't send default speed to non-OpenAI services and accept JSON base64 audio #468

Open
unknown opened this pull request with 188 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 19, 2026 04:43 UTC
Author

Fixes #463

Root cause: OpenAiAPIService::requestSpeechCreation() always adds speed to the /audio/speech payload and returns the response as parsed. Strict OpenAI-compatible APIs such as Mistral reject unknown body fields (422 extra_forbidden on speed), and they answer with JSON {"audio_data": "<base64>"} instead of binary audio, which TextToSpeechProvider reports as "no speech returned" because it only looks for body.

Fix:

  • speed is always sent to OpenAI; for other services it is only sent when it differs from the default 1, so a custom speed still works for LocalAI-style servers that support it.

  • A JSON response containing audio_data is base64-decoded and returned in the same body/content-type shape as a binary response (binary responses are untouched).
  • Tests: new tests/unit/Service/OpenAiAPIServiceSpeechTest.php (5 tests) mocks request() and checks the payload and the response shape. 2 of them fail on main and all 5 pass with the change (plain PHPUnit 10.5 on PHP 8.4 with nextcloud/ocp; the existing OpenAiProviderTest needs a full server and was not run).

    The existing MultiServiceTest::testTextToSpeechProvider (non-OpenAI service) expected 'speed' => 1 in the request body; that expectation was updated (the field is no longer sent). It needs a full Nextcloud server, so it was not run locally.

    AI disclosure: this change was prepared with the assistance of an AI coding agent (Claude); the commit carries an Assisted-by trailer.

    Diff: 188 lines (+141 / -47) across 2 files Reviewer: pcbeingused333 Review duration: 10683m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.41) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.41 · 188 lines diff across 2 files
    0.41
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.314
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #468"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.8% (MEDIUM) · Higher = larger blast radius
    40.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.3% · Safe to merge
    23.3%