Repository navigation
Realtime API による読み上げで、テキストに応答せずそのまま読み上げるよう修正 - #1254
Merged
Merged
Conversation
gpt-realtime-2.1-mini is conversational, so sending the text as a user message made it answer the text (e.g. "こんにちは" -> "はい、こんにちは…") rather than read it aloud. Instruct the session to act as a TTS engine, wrap the input in <text> tags, and send it as an out-of-band response input with conversation: 'none' and minimal reasoning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
えへ~ ありがとう! レビューさせてもらうにゃ! |
|
Contributor
|
🤖 I'm sorry @hakatashi, but I was unable to process your request. Please see the logs for more details. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1254 +/- ##
==========================================
+ Coverage 35.96% 36.21% +0.24%
==========================================
Files 241 241
Lines 20081 20082 +1
Branches 4299 4300 +1
==========================================
+ Hits 7222 7272 +50
+ Misses 10469 10426 -43
+ Partials 2390 2384 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.



概要
#1248 で Discord の TTS を
gpt-realtime-2.1-mini(Realtime API)に移行しましたが、読み上げたいテキストをユーザー発言として送っていたため、モデルがテキストに応答してしまっていました(例: 「こんにちは」→「はい、こんにちは。本日はどのような要件ですか?」)。変更内容 (
lib/openai.ts)<text>タグ内のテキストを一字一句そのまま読み上げ、応答・補足・翻訳などをしない」という固定文にし、呼び出し側から渡されるinstructions(口調などの指定)は# Voice styleとして後ろに付け足すようにしたconversation.item.createをやめ、response.createにconversation: 'none'とinput(<text>…</text>で囲んだテキスト)を直接渡すようにしたreasoning: {effort: 'minimal'}を指定したlib/openai.test.tsに、送信イベントの内容と WAV の組み立てを検証するテストを追加した動作確認
実際の API で、出力音声の書き起こしを修正前後で比較しました。
npx vitest run lib/openai.test.ts通過npx tsgo --noEmitで該当ファイルにエラーなし補足
OpenAI の Deprecations ページによると、
tts-1/tts-1-hd/gpt-4o-mini-tts(全スナップショット)はすべて 2027-01-06 に提供終了し、案内されている移行先はgpt-realtime-2.1-miniのみで、deprecated でない専用 TTS モデルは現状ありません。そのため Realtime モデルを読み上げ専用に絞って使う形にしています。プロンプトによる制御なので完全な保証はなく、崩れるケースが見つかった場合は書き起こしと原文を比較して再試行する仕組みの追加を検討します。🤖 Generated with Claude Code