Play Streaming
The playStream action allows you to stream an audio file in base64 format to the caller. This can be used to greet the caller with specific pre-recorded music or to play audio during the call. Supported audio types include raw
, mp3
, wav
, and ogg
formats. You can also specify the desired audio quality by setting the sample rate.
- Node.js
- Python
To stream base64-encoded audio during a call using the PIOPIY PCMO platform, you can use the playStream
method of the StreamAction
class. The method requires the base64-encoded audio file, the audio type (e.g., raw, mp3, wav, ogg), and the desired sample rate.
const { StreamAction } = require("piopiy");
const stream = new StreamAction();
stream.playStream("Your base64 audio data", "raw", 8000);
Parameters type and description
Parameter | Type | Description |
---|---|---|
audio_base64 | string | The base64-encoded audio data to be streamed. Ensure it is a valid base64 string representing the audio content. |
audio_type | string | The type of the audio file. Supported formats are raw, mp3, wav, and ogg. |
sample_rate | number | The desired voice quality in bits per second. Options are 8000, 16000. |
To stream base64-encoded audio during a call using the PIOPIY PCMO platform, you can use the playStream
method of the StreamAction
class. The method requires the base64-encoded audio file, the audio type (e.g., raw, mp3, wav, ogg), and the desired sample rate.
from piopiy import StreamAction
stream = StreamAction()
stream.playStream(audio_base64="Your base64 audio data", audio_type="raw",sample_rate=8000)
Parameters type and description
Parameter | Type | Description |
---|---|---|
audio_base64 | string | The base64-encoded audio data to be streamed. Ensure it is a valid base64 string representing the audio content. |
audio_type | string | The type of the audio file. Supported formats are raw, mp3, wav, and ogg. |
sample_rate | number | The desired voice quality in bits per second. Options are 8000, 16000. |