{"record":{"id":"6e06567c992dec83","repo":"FoundationAgents/MetaGPT","slug":"azure-tts-subscription-key-azure-tts-region-ifly","errorCode":null,"errorMessage":"azure_tts_subscription_key, azure_tts_region, iflytek_app_id, iflytek_api_key, iflytek_api_secret error","messagePattern":"azure_tts_subscription_key, azure_tts_region, iflytek_app_id, iflytek_api_key, iflytek_api_secret error","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"metagpt/learn/text_to_speech.py","lineNumber":68,"sourceCode":"        if url:\n            return f\"[{text}]({url})\"\n        return audio_declaration + base64_data if base64_data else base64_data\n\n    iflytek_app_id = config.iflytek_app_id\n    iflytek_api_key = config.iflytek_api_key\n    iflytek_api_secret = config.iflytek_api_secret\n    if iflytek_app_id and iflytek_api_key and iflytek_api_secret:\n        audio_declaration = \"data:audio/mp3;base64,\"\n        base64_data = await oas3_iflytek_tts(\n            text=text, app_id=iflytek_app_id, api_key=iflytek_api_key, api_secret=iflytek_api_secret\n        )\n        s3 = S3(config.s3)\n        url = await s3.cache(data=base64_data, file_ext=\".mp3\", format=BASE64_FORMAT)\n        if url:\n            return f\"[{text}]({url})\"\n        return audio_declaration + base64_data if base64_data else base64_data\n\n    raise ValueError(\n        \"azure_tts_subscription_key, azure_tts_region, iflytek_app_id, iflytek_api_key, iflytek_api_secret error\"\n    )\n","sourceCodeStart":50,"sourceCodeEnd":71,"githubUrl":"https://github.com/FoundationAgents/MetaGPT/blob/11cdf466d042aece04fc6cfd13b28e1a70341b1f/metagpt/learn/text_to_speech.py#L50-L71","documentation":"text_to_speech supports Azure TTS and iFlytek TTS; the shown tail raises ValueError when the iFlytek triple (app_id, api_key, api_secret) is incomplete (the Azure branch above already failed to match its own key/region pair). Effectively: no complete TTS credential set was found in config.","triggerScenarios":"Calling text_to_speech without azure_tts_subscription_key + azure_tts_region set, and with any one of iflytek_app_id / iflytek_api_key / iflytek_api_secret missing or empty.","commonSituations":"Only partial iFlytek credentials pasted into config; env vars IFLYTEK_API_SECRET etc. unset; running TTS-dependent agents (e.g. audio output) without configuring any TTS vendor.","solutions":["Provide the complete Azure pair: azure_tts_subscription_key and azure_tts_region.","Or provide all three iFlytek values: iflytek_app_id, iflytek_api_key, iflytek_api_secret.","Verify with a quick config print that none of the chosen vendor's fields is empty/None before invoking TTS."],"exampleFix":"# before: only app_id set -> ValueError\niflytek_app_id: \"123456\"\n\n# after\niflytek_app_id: \"123456\"\niflytek_api_key: \"xxxx\"\niflytek_api_secret: \"yyyy\"","handlingStrategy":"validation","validationCode":"from metagpt.config2 import config\n\ndef tts_available() -> bool:\n    azure = bool(config.azure_tts_subscription_key and config.azure_tts_region)\n    iflytek = bool(config.iflytek_app_id and config.iflytek_api_key and config.iflytek_api_secret)\n    return azure or iflytek","typeGuard":null,"tryCatchPattern":"try:\n    audio = await text_to_speech(text)\nexcept ValueError as e:\n    if \"azure_tts_subscription_key\" in str(e):\n        audio = None  # gracefully skip audio output\n    else:\n        raise","preventionTips":["Configure one complete vendor set (Azure pair or all three iFlytek values) — never partial.","Startup-check TTS credentials when your agent produces audio."],"tags":["tts","configuration","credentials","azure","iflytek"],"backgroundTag":null,"analyzedSha":"11cdf466d042aece04fc6cfd13b28e1a70341b1f","analyzedAt":"2026-08-14T23:20:02.994Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}