Speech synthesis module – text-to-speech solution based on the Doubao voice large model
volc.tts) speech synthesis APIThis capability is currently available only to users who have completed enterprise authentication. To test or for formal integration, please complete the Volcano Engine enterprise authentication process first.
Input column name | Note |
|---|---|
texts | An array of input texts, each element is a string |
String array, audio results generated from text;
If recognition fails or the input is an empty string, the corresponding element will be None
If a parameter does not have a default value, it is required
Parameter name | Type | Default value | Description |
|---|---|---|---|
appid | str | None | AppID obtained from the Volcano Engine console |
token | str | None | Access Token obtained from the Volcano Engine console |
uid | str | None | User identifier, used for API call tracking |
cluster | str | volcano_tts | Name of the service cluster used for integration. Default value: "volcano_tts" |
voice_type | str | zh_female_wanqudashu_moon_bigtts | Timbre type. Default value: "zh_female_wanqudashu_moon_bigtts" |
encoding | str | mp3 | Audio encoding format (such as "mp3", "pcm"). Default value: "mp3" |
speed_ratio | float | 1.0 | Speech rate adjustment ratio. Default value: 1.0 |
rate | int | 24000 | Sampling rate. Default value: 24000 |
bitrate | int | 160 | Audio bitrate (unit: kbps). Default value: 160 |
enable_emotion | bool | False | Whether to enable emotional timbre. Default value: False |
emotion | str | happy | Emotion type, such as "happy", "angry". Default value: "happy" |
emotion_scale | int | 4 | Emotion intensity, range 1~5. Default value: 4 |
extra_audio_params | dict or None | None | Other audio parameters (optional, pass a dictionary for additional settings). Default value: None |
extra_request_params | dict or None | None | Other request parameters (optional, pass a dictionary for additional settings). Default value: None |
timeout | int | 60 | Timeout for a single request (seconds) Default value: 60 |
num_coroutines | int | 1 | Concurrent request control. Default value: 1 |
The following code demonstrates how to use daft to run the operator and convert text to speech.
from __future__ import annotations import os import daft from daft import col from daft.las.functions.audio.audio_tts_doubao import AudioTtsDoubao from daft.las.functions.udf import las_udf if __name__ == "__main__": # Read authentication information for Doubao speech service from environment variables: # - OPENSPEECH_APPID: Application ID, used to identify the caller # - OPENSPEECH_TOKEN: Access token, used for API authentication appid = os.getenv("OPENSPEECH_APPID") token = os.getenv("OPENSPEECH_TOKEN") if os.getenv("DAFT_RUNNER", "native") == "ray": import logging import ray def configure_logging(): logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) logging.getLogger("tracing.span").setLevel(logging.WARNING) logging.getLogger("daft_io.stats").setLevel(logging.WARNING) logging.getLogger("DaftStatisticsManager").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaScheduler").setLevel(logging.WARNING) logging.getLogger("DaftFlotillaDispatcher").setLevel(logging.WARNING) ray.init(dashboard_host="0.0.0.0", runtime_env={"worker_process_setup_hook": configure_logging}) daft.set_runner_ray() daft.set_execution_config(actor_udf_ready_timeout=600) daft.set_execution_config(min_cpu_per_task=0) samples = { "text_input": [ "", ] } df = daft.from_pydict(samples) df = df.with_column( "tts_audio", las_udf( AudioTtsDoubao, construct_args={ "appid": appid, "token": token, "uid": "test", "concurrency": 1, "timeout": 60, }, num_cpus=1, batch_size=1, concurrency=1, )(col("text_input")), ) df.show() # ╭─────────────────────────────────────────────┬────────────────────────────────╮ # │ text_input ┆ tts_audio │ # │ --- ┆ --- │ # │ Utf8 ┆ Binary │ # ╞═════════════════════════════════════════════╪════════════════════════════════╡ # │ Welcome to the Doubao Speech Large Model. This is a demonstration. … ┆ b"\xff\xf3\xe4\xc4\x00\x00\x0… │ # ╰─────────────────────────────────────────────┴────────────────────────────────╯