Skip to content

Conversation

@SyedaAnshrahGillani
Copy link
Contributor

@SyedaAnshrahGillani SyedaAnshrahGillani commented Sep 30, 2025

Background

The _process_audio_block method in the AgentBase class included a TODO comment to implement playback of audio from a URL. This functionality was missing, limiting the agent's ability to handle audio content provided as a web link.

Purpose

This pull request implements that missing feature, enabling agents to process and play audio directly from a URL.

Changes Made

This PR enhances the _process_audio_block method to support audio sources from URLs. The changes include:

  • Using the urllib.request module to download the audio file from the given URL.
  • Storing the downloaded audio content in a temporary file.
  • Employing the wave module to read the audio data from the temporary file.
  • Utilizing the sounddevice library to play the audio.
  • Incorporating error handling to gracefully manage potential issues during download or playback.

How to Test

  1. Create an agent that receives a message containing an audio block with a source type of "url".
  2. The URL should point to a valid .wav file.

Example message content:

{
  "type": "audio",
  "source": {
    "type": "url",
    "url": "https://example.com/path/to/audio.wav"
  }
}

Checklist

Please verify the following before marking the PR ready for review:

  • Code has been formatted with pre-commit run --all-files
  • All tests are passing
  • Docstrings follow Google style
  • Related documentation has been updated (e.g., links, examples, etc.)
  • Code is ready for review

@DavdGao DavdGao requested a review from qbc2016 October 9, 2025 03:03
Copy link
Member

@DavdGao DavdGao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, and thank you for your contribution

@DavdGao DavdGao merged commit 7a61962 into agentscope-ai:main Oct 20, 2025
10 checks passed
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.

2 participants