Write the Code. Change the World.

分类目录
12月 14

在自己的服务器环境使用语音转视频,需要配置 ice server。而这个玩意先得创建通信资源。创建通信资源,在后台就可以实现。ice server 可以使用编程语言去获取。

相关文档

https://learn.microsoft.com/en-us/azure/ai-services/speech-service/text-to-speech-avatar/what-is-text-to-speech-avatar

https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/js/browser/avatar/README.md

https://learn.microsoft.com/zh-cn/azure/communication-services/quickstarts/relay-token?pivots=programming-language-python#getting-the-relay-configuration

代码

这里以 python 来获取。只需要准备好连接字符串(endpoint)就好,这个就是需要去后台创建通信资源。

# issue-relay-tokens.py
from azure.communication.networktraversal import CommunicationRelayClient
from azure.identity import DefaultAzureCredential
from azure.communication.identity import CommunicationIdentityClient

# You can find your endpoint and access token from your resource in the Azure Portal
connection_str = "endpoint=https://xxxx.communication.azure.com/;accesskey=xxxx"
endpoint = "https://xxxx.communication.azure.com/"

# To use Azure Active Directory Authentication (DefaultAzureCredential) make sure to have
# AZURE_TENANT_ID, AZURE_CLIENT_ID and AZURE_CLIENT_SECRET as env variables.
# We also need Identity client to get a User Identifier
# identity_client = CommunicationIdentityClient(endpoint, DefaultAzureCredential())
# relay_client = CommunicationRelayClient(endpoint, DefaultAzureCredential())

#You can also authenticate using your connection string
identity_client = CommunicationIdentityClient.from_connection_string(connection_str)
relay_client = CommunicationRelayClient.from_connection_string(connection_str)

identity_client.create_user()

relay_configuration = relay_client.get_relay_configuration()

for iceServer in relay_configuration.ice_servers:
    assert iceServer.username is not None
    print('Username: ' + iceServer.username)

    assert iceServer.credential is not None
    print('Credential: ' + iceServer.credential)

    assert iceServer.urls is not None
    for url in iceServer.urls:
        print('Url:' + url)

执行 python .\issue-relay-tokens.py,如果配置都正确,就会得到 ice 相关信息。

Username: xxx1
Credential: cre1
Url:stun:relay.communication.microsoft.com:3478
Url:turn:relay.communication.microsoft.com:3478
Username: xxx2
Credential: cre2
Url:stun:20.202.255.225:3478
Url:turn:20.202.255.225:3478

转换截图

12月 13

通过文字输入,输出视频+语音虚拟形象输出。可以尝试尝试。

使用微软 Speech Studio

样例
https://speech.microsoft.com/portal/talkingavatar

训练声音
https://speech.microsoft.com/portal/customvoice/overview

精简版训练
https://learn.microsoft.com/zh-cn/azure/ai-services/speech-service/custom-neural-voice-lite

申请授权
https://speech.microsoft.com/portal/customvoice/accessrequirement