Skip to content

fix(asr): keep source audio files and per-client credentials - #1203

Open
aduoge wants to merge 1 commit into
volcengine:mainfrom
aduoge:fix/asr-keep-source-and-credentials
Open

aduoge wants to merge 1 commit into
volcengine:mainfrom
aduoge:fix/asr-keep-source-and-credentials

Conversation

@aduoge

@aduoge aduoge commented Nov 3, 2026

Copy link
Copy Markdown

Two bugs in veadk/toolkits/audio/asr/asr_client.py.

The caller's audio file is deleted. For non-WAV input, CommonUtils.convert_wav_with_path runs ffmpeg with output to stdout and then calls os.remove(audio_path). The converted audio only exists in memory, so AsrWsClient.execute("meeting.mp3") / read_audio_data(...) removes the user's original recording, even when the ASR request fails afterwards. The client doesn't create that file and shouldn't delete it, so this PR drops the removal.

Clients share credentials. AsrWsClient.__init__ writes app_id / access_token into the module-level config, and create_connection builds headers from that global. With two clients in one process, the first one connects with the second one's X-Api-App-Key / X-Api-Access-Key. Each client now keeps its own Config and passes it to RequestBuilder.new_auth_headers(auth_config). The parameter defaults to the module-level config, and the constructor still updates that config, so existing direct callers of new_auth_headers() behave as before.

Tests

New tests/toolkits/test_asr_client.py (ffmpeg and the websocket session are mocked, no network):

  • test_read_audio_data_preserves_non_wav_source
  • test_connections_use_each_clients_credentials
  • test_auth_header_builder_keeps_default_call_compatible (compatibility check, passes before and after)

On main: 2 failed, 1 passed. On this branch: 3 passed.

Full suite (uv run --extra dev pytest -n 4 -m "not codex_smoke and not piagent_smoke"): 26 failed, 2 errors, 8052 passed. The same 28 failures/errors occur on unmodified main in my environment (tests/runtime/codex/*, tests/cloud/test_harness_app_contract.py, tests/frontend/test_migration_delivery_recovery.py, tests/runtime/test_self_host_sandbox_*), so none are new. Ruff 0.11.12 (the pre-commit version) check and format --check are clean on the changed files.

- convert_wav_with_path deleted the caller's input file after a
  successful ffmpeg conversion. The converted audio only lives in
  memory, so the original recording was lost. Stop deleting it.
- AsrWsClient wrote its credentials into the module-level config and
  every connection read them from there, so creating a second client
  made the first one connect with the second one's app key and token.
  Keep credentials on the instance and pass them to new_auth_headers;
  the default argument keeps existing callers working.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant