Skip to content

Build and run agents you can see, understand and trust.

fix(asr): let per-call options override the transcribe defaults (#3333)

lihongyuan992d9e237e379b
diff --git a/src/agentscope/asr/_openai/_model.py b/src/agentscope/asr/_openai/_model.py
index 2ccc960c9..dafd5de8e 100644
--- a/src/agentscope/asr/_openai/_model.py
+++ b/src/agentscope/asr/_openai/_model.py
@@ -60,12 +60,13 @@ class OpenAIASRModel(ASRModelBase):
if not filename:
raise ValueError("filename must not be empty")
- options = self.parameters.model_dump(exclude_none=True)
- options.update(kwargs)
- result = await self.client.audio.transcriptions.create(
- file=(filename, audio),
- model=self.model,
- response_format="json",
- **options,
- )
- return ASRResponse(content=TextBlock(text=result.text))
+ api_kwargs: dict[str, Any] = {
+ "file": (filename, audio),
+ "model": self.model,
+ "response_format": "json",
+ **self.parameters.model_dump(exclude_none=True),
+ **kwargs,
+ }
+ result = await self.client.audio.transcriptions.create(**api_kwargs)
+ text = result if isinstance(result, str) else result.text
+ return ASRResponse(content=TextBlock(text=text))