### Setup Project Environment Source: https://www.volcengine.com/docs/6561/2227958?lang=zh Sets up a new project directory, extracts a code archive, activates a virtual environment, and installs project dependencies. This is required before running the code examples. ```bash mkdir -p volcengine_get_voice_demo tar xvzf volcengine_get_voice_demo.tar.gz -C ./volcengine_get_voice_demo cd volcengine_get_voice_demo python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip pip3 install -e . ``` -------------------------------- ### Start Session Payload Example Source: https://www.volcengine.com/docs/6561/1739229?lang=zh Example JSON payload for starting a session, including speaker and audio generation parameters like emotion and loudness. ```JSON {"user":{"uid":"YOURUID"},"req_params":{"speaker":"zh_female_roumeinvyou_emo_v2_mars_bigtts","audio_params":{"emotion":"excited","loudness_rate":50}}} ``` -------------------------------- ### Run Realtime Dialog API Examples Source: https://www.volcengine.com/docs/6561/1594356?lang=zh Commands to execute the Realtime Dialog API examples for Go and Python after installation. The Go command includes a verbosity flag. ```Shell go run . -v=0 ``` ```Shell python main.py ``` -------------------------------- ### Main Method for Volcengine API Interaction Setup in Java Source: https://www.volcengine.com/docs/6561/1476626?lang=zh This is the main entry point for the example, setting up initial parameters like Access Key ID, Secret Access Key, endpoint, and service details for signing API requests. ```java public static void main(String[] args) throws Exception { String AccessKeyID = ""; String SecretAccessKey = ""; String endpoint = "open.volcengineapi.com"; String path = "/"; String service = "speech_saas_prod"; String region = "cn-north-1"; String schema = "https"; Sign sign = new Sign(region, service, schema, endpoint, path, AccessKeyID, SecretAccessKey); } ``` -------------------------------- ### Setup Project Environment Source: https://www.volcengine.com/docs/6561/2227958?lang=zh This sequence of commands sets up a new project environment, installs dependencies, and activates a virtual environment. It's recommended for managing project-specific packages. ```bash mkdir -p volcengine_upgrade_voice_demo tar xvzf volcengine_upgrade_voice_demo.tar.gz -C ./volcengine_upgrade_voice_demo cd volcengine_upgrade_voice_demo python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip pip3 install -e . ``` -------------------------------- ### Setup Voice Cloning Demo Environment Source: https://www.volcengine.com/docs/6561/2227958?lang=zh These commands set up the voice cloning demo environment by creating a directory, extracting the code package, creating a virtual environment, activating it, and installing project dependencies. ```bash mkdir -p volcengine_voice_clone_demo tar xvzf volcengine_voice_clone_demo.tar.gz -C ./volcengine_voice_clone_demo cd volcengine_voice_clone_demo python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip pip3 install -e . ``` -------------------------------- ### Install Python Dependencies Source: https://www.volcengine.com/docs/6561/1329505?lang=zh Installs and upgrades pip, then installs the project dependencies in a virtual environment. This is a prerequisite for running Python examples. ```bash python3 -m pip install --upgrade pip ``` ```bash mkdir -p volcengine_bidirection_demo tar xvzf volcengine_bidirection_demo.tar.gz -C ./volcengine_bidirection_demo cd volcengine_bidirection_demo python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip pip3 install -e . ``` -------------------------------- ### Install Python Dependencies Source: https://www.volcengine.com/docs/6561/2228192?lang=zh Installs project dependencies and sets up a virtual environment for Python. This is required before running the Python speech synthesis example. ```Bash mkdir -p volcengine_binary_demo tar xvzf volcengine_binary_demo.tar.gz -C ./volcengine_binary_demo cd volcengine_binary_demo python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip pip3 install -e . ``` -------------------------------- ### Receive Connection Established - SessionStarted Example Source: https://www.volcengine.com/docs/6561/1756902?lang=zh This is an example of the server response indicating that the connection has been successfully established. ```json { "event": event.Type_SessionStarted } ``` -------------------------------- ### Install Python SDK Dependencies Source: https://www.volcengine.com/docs/6561/1668014?lang=zh Sets up a Python virtual environment and installs the Speech SDK and its dependencies. ```bash mkdir -p volcengine_podcasts_demo tar xvzf volcengine_podcasts_demo.tar.gz -C ./volcengine_podcasts_demo cd volcengine_podcasts_demo python3 -m venv .venv source .venv/bin/activate python3 -m pip install --upgrade pip pip3 install -e . ``` -------------------------------- ### Text-to-Speech Request Example Source: https://www.volcengine.com/docs/6561/2277844?lang=zh This JSON object demonstrates a sample request payload for the Volcengine Text-to-Speech API. It includes parameters for text prompts and image prompts, specifying voice characteristics and providing image data via base64 encoding. ```json { "prompt": { "text_prompt": "女性,语速中等偏快,语调低沉有力", "image_prompt": { "image_bytes": ``` -------------------------------- ### Voice Design API Response Example Source: https://www.volcengine.com/docs/6561/2277844?lang=zh This JSON object represents a successful response from the Voice Design API, indicating available training times, creation time, language, speaker ID, demo audio URL, and training status. ```json { "available_training_times": 15, "create_time": 1772026663000, "language": 0, "speaker_id": "S_*******", "demo_audio": "https://lf6-lab-speech-tt-sign.bytespeech.com/tos-cn-o-14155/o0ftE0YFM8eECAX78jC3AHopgAijApN6uMBCAi?x-expires=1773912669&x-signature=g7ui2EQVJ0PShNKC%2BArg%2Bf7ZdoQ%3D", "status": 2 } ``` -------------------------------- ### Voice Design API Error Response Example Source: https://www.volcengine.com/docs/6561/2277844?lang=zh This JSON object illustrates an error response from the Voice Design API, typically returned when an operation fails. It includes an error code and a detailed error message. ```json { "code": 45001001, "message": "请求参数有误" } ``` -------------------------------- ### 指定模型下载路径 Source: https://www.volcengine.com/docs/6561/516112?lang=zh 在调用`setup`之前指定模型下载路径。建议此路径不存放其他文件,因为模型升级时可能会清空该目录。该路径需要是一个已存在的目录。 ```objectivec /// 指定模型下载路径,这个路径建议不要放其它文件,在模型升级时可能会先清空 /// 须在 `setup` 之前调用 /// @param rootPath 模型下载路径,需要是已经存在的目录 - (void)setRootPath:(NSString*)rootPath; ``` -------------------------------- ### HTTP Request Example Source: https://www.volcengine.com/docs/6561/1756902?lang=zh Example of an HTTP GET request to the translation API, including necessary headers. ```APIDOC ## 建连 HTTP 请求头示例 # ``` GET /api/v4/ast/v2/translate Host: openspeech.bytedance.com X-Api-App-Key: 123456789 X-Api-Resource-Id: volc.service_type.10053 # 返回 Header X-Tt-Logid: 202407261553070FACFE6D19421815D605 Plain ``` ``` -------------------------------- ### 设置语音SDK的引擎名称 Source: https://www.volcengine.com/docs/6561/516112?lang=zh 在调用`setup`之前设置语音SDK的引擎名称,该名称应与`SE_PARAMS_KEY_ENGINE_NAME_STRING`的配置值相同。 ```objectivec /// 设置语音SDK的引擎名称 /// 应该和 SE_PARAMS_KEY_ENGINE_NAME_STRING 的配置值相同 /// 须在 `setup` 之前调用 /// @param engineName 引擎名称 - (void)setSpeechEngineName:(NSString*)engineName; ``` -------------------------------- ### Install PortAudio on macOS Source: https://www.volcengine.com/docs/6561/1594356?lang=zh Installs the PortAudio library on macOS using Homebrew. This is a prerequisite for running the Realtime Dialog API examples. ```Bash brew install portaudio ``` -------------------------------- ### 指定是否使用线上模型 Source: https://www.volcengine.com/docs/6561/516112?lang=zh 在调用`setup`之前指定是否使用线上资源,对于无特殊需求的情况,建议设置为TRUE。 ```objectivec /// 是否使用线上资源 /// 须在 `setup` 之前调用 /// @param useOnlineModel 无特殊需求设置为 TRUE - (void)setOnlineModelEnable:(BOOL)useOnlineModel; ``` -------------------------------- ### Install PortAudio on Debian/Ubuntu Source: https://www.volcengine.com/docs/6561/1594356?lang=zh Installs the PortAudio development library on Debian/Ubuntu using apt-get. This is a prerequisite for running the Realtime Dialog API examples. ```Shell sudo apt-get install portaudio19-dev ``` -------------------------------- ### Run .NET Speech SDK Example Source: https://www.volcengine.com/docs/6561/1668014?lang=zh Execute the .NET Speech SDK example by providing your App ID, Access Token, and the text for podcast generation. Ensure you replace placeholders with your actual credentials. ```bash dotnet run --project Volcengine/Podcasts/Volcengine.Speech.Podcasts.csproj -- --appid --access_token --text "介绍下火山引擎" ``` -------------------------------- ### 设置引擎类型 Source: https://www.volcengine.com/docs/6561/516112?lang=zh 设置语音SDK的引擎名称,应与 `SE_PARAMS_KEY_ENGINE_NAME_STRING` 的配置值相同。须在 `setup` 之前调用。 ```APIDOC ## 设置引擎类型 ``` /// 设置语音SDK的引擎名称 /// 应该和 SE_PARAMS_KEY_ENGINE_NAME_STRING 的配置值相同 /// 须在 `setup` 之前调用 /// @param engineName 引擎名称 - (void)setSpeechEngineName:(NSString*)engineName; objectivec ``` ``` -------------------------------- ### Install PortAudio on CentOS Source: https://www.volcengine.com/docs/6561/1594356?lang=zh Installs the PortAudio library and development files on CentOS using yum. This is a prerequisite for running the Realtime Dialog API examples. ```Bash sudo yum install -y portaudio portaudio-devel ``` -------------------------------- ### Run Node.js Speech SDK Example Source: https://www.volcengine.com/docs/6561/1668014?lang=zh Execute the Node.js Speech SDK example using ts-node. Provide your App ID, Access Token, and the text for podcast generation. Replace placeholders with your actual credentials. ```bash npx ts-node src/volcengine/podcasts.ts --appid --access_token --text "介绍下火山引擎" ``` -------------------------------- ### Translated Text Start - TranslationSubtitleStart Example Source: https://www.volcengine.com/docs/6561/1756902?lang=zh Marks the beginning of the translated text transmission. Includes the start timestamp and a speaker change signal if related features are enabled. ```json { "event": event.Type_TranslationSubtitleStart, "start_time": xxx, "spk_chg": false //默认为false,如果检测到此句说话人发生切换,那么为true } ``` -------------------------------- ### 指定是否使用线上模型 Source: https://www.volcengine.com/docs/6561/516112?lang=zh 指定是否使用线上资源。无特殊需求时设置为 TRUE。须在 `setup` 之前调用。 ```APIDOC ## 指定是否使用线上模型 ``` /// 是否使用线上资源 /// 须在 `setup` 之前调用 /// @param useOnlineModel 无特殊需求设置为 TRUE - (void)setOnlineModelEnable:(BOOL)useOnlineModel; objectivec ``` ``` -------------------------------- ### Original Text Start - SourceSubtitleStart Example Source: https://www.volcengine.com/docs/6561/1756902?lang=zh Marks the beginning of the original text transmission. Includes the start timestamp and a speaker change signal if related features are enabled. ```json { "event": event.Type_SourceSubtitleStart, "start_time": xxx, "spk_chg": false //默认为false,如果检测到此句说话人发生切换,那么为true } ``` -------------------------------- ### Query Speech API Task Result Example Source: https://www.volcengine.com/docs/6561/80909?lang=zh Example of an HTTP GET request to query the status or result of a speech processing task using the task ID. ```http GET /api/v1/vc/query?appid=lv&id=fc5aa03e-6ae4-46a3-b8cf-1910a44e0d8a HTTP/1.1 Host: openspeech.bytedance.com ``` -------------------------------- ### Example Text Response with Timestamps Source: https://www.volcengine.com/docs/6561/1598757?lang=zh An example of a text response containing synthesized text and detailed word-level timing information, including start time, end time, and confidence scores. ```json { "code": 0, "message": "", "data": null, "sentence": { "text": "其他人。", "words": [ { "confidence": 0.8531248, "endTime": 0.315, "startTime": 0.205, "word": "其" }, { "confidence": 0.9710379, "endTime": 0.515, "startTime": 0.315, "word": "他" }, { "confidence": 0.9189944, "endTime": 0.815, "startTime": 0.515, "word": "人。" } ] } } ``` -------------------------------- ### Query Synthesis Result Request Example Source: https://www.volcengine.com/docs/6561/1096680?lang=zh This is an example of a GET request to query the status of a text-to-speech synthesis task. Ensure you replace placeholder values with your actual AppID and Task ID. ```http https://openspeech.bytedance.com/api/v1/tts_async/query?appid=123456&task_id=bd0c2171-4b38-4c05-b685-11f3d240ee8d ``` -------------------------------- ### Set TTS Voice Type Source: https://www.volcengine.com/docs/6561/516112?lang=zh Specify the TTS voice type(s) to be used. Examples include 'BV001_streaming' and 'BV002_streaming'. Must be called before `setup`. ```objectivec /// 设置想要使用的 TTS 音色 /// 须在 `setup` 之前调用 /// @param voiceTypes 如 @[@"BV001_streaming", @"BV002_streaming"] - (void)setTtsVoiceType:(NSArray*)voiceType; ``` -------------------------------- ### Demonstrate API Request Signing in Java Source: https://www.volcengine.com/docs/6561/1476625?lang=zh Main method to set up API credentials, endpoint, and parameters, then initiate a signed GET request using the Sign class. ```Java public static void main(String[] args) throws Exception { String AccessKeyID = ""; String SecretAccessKey = ""; String endpoint = "open.volcengineapi.com"; String path = "/"; String service = "speech_saas_prod"; String region = "cn-north-1"; String schema = "https"; Sign sign = new Sign(region, service, schema, endpoint, path, AccessKeyID, SecretAccessKey); String version = "2021-08-30"; Date date = new Date(); String action = "UsageMonitoring"; Map queryParams = Map.of( "AppID", "APPID真实值", "ResourceID", "ResourceID真实值", "Start", "2025-02-23", "End", "2025-02-25", "Mode", "daily" ); sign.doRequest("GET", queryParams, null, date, action, version); } } ``` -------------------------------- ### List API Keys Request Example Source: https://www.volcengine.com/docs/6561/1801323?lang=zh This example demonstrates how to make a POST request to list API keys. Ensure the Host, Content-Type, X-Date, X-Content-Sha256, and Authorization headers are correctly set. ```text POST /?Action=ListAPIKeys&Version=2025-05-20 HTTP/1.1 Host: https://open.volcengineapi.com Content-Type: application/json; charset=UTF-8 X-Date: 20250819T031544Z X-Content-Sha256: 287e874e******d653b44d21e Authorization: HMAC-SHA256 Credential=Adfks******wekfwe/20250819/cn-beijing/speech_saas_prod/request, SignedHeaders=host;x-content-sha256;x-date, Signature=47a7d934ff7b37c03938******cd7b8278a40a1057690c401e92246a0e41085f { "ProjectName": "default", "OnlyAvailable": true } ``` -------------------------------- ### Original Text End - SourceSubtitleEnd Example Source: https://www.volcengine.com/docs/6561/1756902?lang=zh Marks the end of the original text transmission, including start time, end time, and the full text. ```json { "event": event.Type_SourceSubtitleEnd, "start_time": xxx, "end_time": xxx, "text": "xxx" } ``` -------------------------------- ### 设置appid Source: https://www.volcengine.com/docs/6561/516112?lang=zh 在调用`setup`之前设置从火山申请得到的appid。 ```objectivec /// 设置从火山申请得到的 appid /// 须在 `setup` 之前调用 /// @param appId - (void)setAppId:(NSString*)appId; ``` -------------------------------- ### Go Speech Synthesis Example Source: https://www.volcengine.com/docs/6561/1668014?lang=zh Runs a speech synthesis command using the Volcengine Go SDK. Remember to substitute the placeholder values for App ID, Access Token, and the input text. ```bash go run volcengine/podcasts/main.go --appid --access_token --text "介绍下火山引擎" ``` -------------------------------- ### Android TTS Artifact ID Update Source: https://www.volcengine.com/docs/6561/79830 Starting from version 2022.07.22, the Android TTS component uses a new Maven repository and Artifact ID. Refer to the integration guide for migration if you are using the old component. ```text com.bytedance.speechengine:speechengine_tts_tob:1.0.48.1-bugfix ``` -------------------------------- ### 指定模型存放路径 Source: https://www.volcengine.com/docs/6561/516112?lang=zh 指定模型下载路径。建议此路径不要存放其它文件,因为模型升级时可能会先清空。须在 `setup` 之前调用。 ```APIDOC ## 指定模型存放路径 ``` /// 指定模型下载路径,这个路径建议不要放其它文件,在模型升级时可能会先清空 /// 须在 `setup` 之前调用 /// @param rootPath 模型下载路径,需要是已经存在的目录 - (void)setRootPath:(NSString*)rootPath; objectivec ``` ``` -------------------------------- ### Query Speech API Task Result Source: https://www.volcengine.com/docs/6561/149749?lang=zh Example of an HTTP GET request to query the status or result of a speech processing task. Ensure you replace 'your_appid' with your actual application ID and use the 'id' returned from the submit interface. ```http GET /api/v1/vc/ata/query?appid=your_appid&id=fc5aa03e-6ae4-46a3-b8cf-1910a44e0d8a HTTP/1.1 Host: openspeech.bytedance.com ``` -------------------------------- ### Go Speech Synthesis Example Source: https://www.volcengine.com/docs/6561/2228192?lang=zh Runs the Go program for speech synthesis. Pass your App ID, Access Token, voice type, and the text content as arguments. ```Bash go run volcengine/binary/main.go --appid --access_token --voice_type --text "**你好**,我是火山引擎的语音合成服务。" ``` -------------------------------- ### Start Engine Source: https://www.volcengine.com/docs/6561/1739228?lang=zh Starts the engine by sending the StartSession command. It's recommended to call a synchronous stop first to avoid issues with SDK's internal asynchronous threads. The `startSessionPayload` parameter contains audio generation parameters. ```objectivec // Note: Call synchronous stop first to avoid issues with SDK's internal asynchronous threads [self.engine sendDirective:SEDirectiveSyncStopEngine]; // Start BiTTS engine SEEngineErrorCode ret = [self.engine sendDirective:SEDirectiveStartEngine data: startSessionPayload]; if (ret != SENoError) { NSLog(@"Send directive say hello failed: %d", ret); return; } ``` ```objectivec "{\"user\":{\"uid\":\"YOURUID\"},\"req_params\":{\"speaker\":\"zh_female_roumeinvyou_emo_v2_mars_bigtts\",\"audio_params\":{\"emotion\":\"excited\",\"loudness_rate\":50}}}" ``` -------------------------------- ### Install Python Pip Source: https://www.volcengine.com/docs/6561/1668014?lang=zh Installs or upgrades the pip package installer for Python. ```bash python3 -m pip install --upgrade pip ```