SDK reference

Updated at:

This document describes the versions, download methods, installation instructions, and usage examples for the Alibaba Cloud Voice Service software development kits (SDKs) for various languages. Use this document to quickly integrate Voice Service features.

1. Version guide

1.1. Version overview

The Alibaba Cloud Voice Service OpenAPI Portal provides two SDK versions: V1.0 SDK and V2.0 SDK:

  • V1.0 SDK: The original SDK. This version is no longer maintained.

  • V2.0 SDK: The upgraded SDK. This version improves robustness and user experience.

1.2. Version recommendations

Important:

  • Use the V2.0 SDK.

  • The V2.0 SDK does not change any API features. It only improves the robustness and user experience of the SDK.

  • The V1.0 SDK is no longer maintained. Do not continue to use it.

Note

For a detailed comparison between the V1.0 and V2.0 SDKs, see V2.0 SDK and V1.0 SDK.

2. Download the SDK for each language

2.1. Download methods

The source code for the Voice Service V2.0 SDK is hosted on the open source platform GitHub and is available in major dependency repositories. You can install the SDK using the primary dependency management tool for your programming language.

Note

2.2. SDK download list

Mainstream languages

GitHub address

Latest SDK download address

Java

java-dyvmsapi-20170525

Download Java SDK

Python

python-dyvmsapi-20170525

Download Python SDK

PHP

php-dyvmsapi-20170525

Download PHP SDK

Go

go-dyvmsapi-20170525

Download Go SDK

Node.js

nodejs-dyvmsapi-20170525

Download Node.js SDK

C++

cpp-dyvmsapi-20170525

Download C++ SDK

C#

csharp-dyvmsapi-20170525

Download C# SDK

Swift

swift-dyvmsapi-20170525

Download Swift SDK

2.3. Installation methods

Java SDK

Install using Maven:

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>dyvmsapi20170525</artifactId>
    <version>latest-version</version>
</dependency>

Python SDK

Install using pip:

pip install alibabacloud-dyvmsapi20170525

PHP SDK

Install using Composer:

composer require alibabacloud/dyvmsapi-20170525

Go SDK

Install using go get:

go get github.com/alibabacloud-go/dyvmsapi-20170525

Node.js SDK

Install using npm:

npm install @alicloud/dyvmsapi20170525

3. Usage example

The following example shows how to use the Python SDK to make a voice call to a specific phone number. Example code:

from alibabacloud_dyvmsapi20170525.client import Client as Dyvmsapi20170525Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dyvmsapi20170525 import models as dyvmsapi_20170525_models
from alibabacloud_tea_util import models as util_models

# Create a client instance.
config = open_api_models.Config(
    access_key_id='your-access-key-id',
    access_key_secret='your-access-key-secret',
    endpoint='dyvmsapi.aliyuncs.com'
)
client = Dyvmsapi20170525Client(config)

# Create a request object.
request = dyvmsapi_20170525_models.SingleCallByTtsRequest(
    called_number='1380013****',
    called_show_number='400000****',
    tts_code='TTS_12345****',
    tts_param='{"name":"John Doe"}'
)

# Send the request.
runtime = util_models.RuntimeOptions()
try:
    response = client.single_call_by_tts_with_options(request, runtime)
    print(f"Request ID: {response.body.request_id}")
    print(f"Call ID: {response.body.call_id}")
except Exception as e:
    print(f"Call failed: {e}")

For more detailed examples, see Python SDK call examples.

FAQ