> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # voice.updateConfig() `updateConfig()` 方法可讓你在執行階段更新語音 Provider 的設定。你可以在不建立新執行個體的情況下變更語音設定、API 金鑰或其他 Provider 特定選項。 ## 使用範例 ```typescript import { OpenAIRealtimeVoice } from '@mastra/voice-openai-realtime' // Initialize a real-time voice provider const voice = new OpenAIRealtimeVoice({ realtimeConfig: { model: 'gpt-5.1-realtime', apiKey: process.env.OPENAI_API_KEY, }, speaker: 'alloy', }) // Connect to the real-time service await voice.connect() // Later, update the configuration voice.updateConfig({ voice: 'nova', // Change the default voice turn_detection: { type: 'server_vad', threshold: 0.5, silence_duration_ms: 1000, }, }) // The next speak() call will use the new configuration await voice.speak('Hello with my new voice!') ``` ## 參數 **options** (`Record`): 要更新的設定選項。特定屬性取決於語音 Provider。 ## 傳回值 此方法不會傳回值。 ## 設定選項 不同語音 Provider 支援不同的設定選項: ### OpenAI Realtime **voice** (`string`): 用於語音合成的語音 ID(例如 'alloy'、'echo'、'nova') **turn\_detection** (`{ type: string, threshold?: number, silence_duration_ms?: number }`): 用來偵測使用者何時說完話的設定 ## 注意事項 - 如果 Provider 不支援此方法,預設實作會記錄警告 - 設定更新通常會套用至後續操作,而非進行中的操作 - 並非建構函式中可設定的所有屬性都能在執行階段更新 - 確切行為取決於語音 Provider 的實作 - 對即時語音 Provider 而言,部分設定變更可能需要重新連線至服務