feat: add Astraflow provider support to voice input example#2870
feat: add Astraflow provider support to voice input example#2870ucloudnb666 wants to merge 1 commit into
Conversation
Signed-off-by: ucloudnb666 <ucloudnb666@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a provider shortcut system for the FunASR voice input example, allowing users to switch between local and Astraflow backends via a new --provider flag. It also adds support for API keys through command-line arguments or environment variables. The reviewer suggested simplifying the API key assignment logic by removing an unnecessary getattr call and redundant default value handling.
| else: | ||
| args.apikey = args.apikey or "not-needed" | ||
|
|
||
| api_key = getattr(args, "apikey", None) or "not-needed" |
There was a problem hiding this comment.
The use of getattr(args, "apikey", None) is unnecessary here because apikey is a defined argument in the parser and is guaranteed to exist on the args object. You can simplify this to a direct attribute access. Additionally, the default value logic here makes the else block at lines 88-89 redundant.
api_key = args.apikey or "not-needed"
LauraGPT
left a comment
There was a problem hiding this comment.
LGTM — adds Astraflow as an alternative voice input provider. Clean addition to the example.
|
Thanks for the contribution! However, we'd prefer not to hardcode specific third-party provider endpoints in the codebase. The existing python funasr_input.py --server https://api-us-ca.umodelverse.ai/v1Also note there's an indentation bug in the PR (the We'll close this for now, but feel free to add Astraflow as an example in the documentation or README instead. Thanks for supporting FunASR! |
Summary
Adds Astraflow (by UCloud / 优刻得) as a named provider shortcut in
examples/voice_input/funasr_input.py.Astraflow is an OpenAI-compatible AI model aggregation platform supporting 200+ models. Because the voice input tool already uses the
openaiPython client with a configurablebase_url, wiring in Astraflow requires only:PROVIDER_CONFIGSdict that maps provider names →(base_url, api_key_env).--providerCLI argument that overrides--server/--apikeywhen set.Usage:
Global endpoint (outside China):
export ASTRAFLOW_API_KEY=your_key_here python funasr_input.py --provider astraflow --model sensevoiceChina endpoint:
export ASTRAFLOW_CN_API_KEY=your_key_here python funasr_input.py --provider astraflow-cn --model sensevoiceType of change
Validation
Changes are limited to
examples/voice_input/funasr_input.py: addsPROVIDER_CONFIGS,--provider/--apikeyCLI args, provider resolution logic, and updated usage examples in the docstring. No new files, no new dependencies, no changes to core FunASR model code.python -m compileall funasr examples testsN/A (no screenshots or recordings applicable)
User impact
Users who want to use Astraflow (by UCloud / 优刻得) as their LLM backend — both global users (
ASTRAFLOW_API_KEY) and China-region users (ASTRAFLOW_CN_API_KEY) — can now select it via a single--provider astraflowor--provider astraflow-cnflag without manually specifying--serverand--apikey. This lowers the barrier for new users onboarding with an OpenAI-compatible aggregation platform supporting 200+ models.Notes for reviewers
--providerargument short-circuits--server/--apikeywhen set, so existing CLI usage is fully backward-compatible.https://api-us-ca.umodelverse.ai/v1https://api.modelverse.cn/v1base_urlreplacement)PROVIDER_CONFIGSusing the same pattern.