Skip to content

DapengLi2016/tts-player-pr

Repository files navigation

Introduction

TTS player management client tool

Work Flow

  1. Create TTS player with below command:

TTSPlayerManagementClient.exe createPlayer --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --config "CreatePlayerConfigSample.json"

  1. List all players:

TTSPlayerManagementClient.exe list --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey]

  1. Query player detail by ID:

TTSPlayerManagementClient.exe get --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --id [PlayerId]

  1. Create javascript client demo:

TTSPlayerManagementClient.exe createDemo --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --config CreateDemoConfigSample.json --targetDir [YourLocalDir]

Tool will prompt your demo page can be found here: [YourLocalDir]\client-sample\flat.html

  1. Delete the player if you don't need anymore.

TTSPlayerManagementClient.exe delete --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --id [PlayerId]

  1. You can also get diagnose information of the SSML generated by synthesis API.

TTSPlayerManagementClient.exe synthesisMetadata --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --config CreateDemoConfigSample.json

You can get the full URL from which the server side API will fetch text content from, and you can also get the SSML list which is generated by server, and the SSML will be used for TTS synthesis.

Getting Started

Install .NET 8.0: https://dotnet.microsoft.com/download/dotnet/8.0

Build

Client Management tool solution: TTSPlayerManagementClient.sln

Command Line Usage

Description Command line arguments
List all TTS players. list --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey]
Get TTS player by ID. get --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --id [PlayerId]
Delete TTS player by ID. delete --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --id [PlayerId]
Create TTS Player by config file. createPlayer --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --config "CreatePlayerConfigSample.json"
Create TTS Player javascript client demo. createDemo --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --config "CreateDemoConfigSample.json" --targetDir [YourLocaleDir]
Query synthesis metadata information. synthesisMetadata --region [RegionIdentifier] --subscriptionKey [YourSpeechResourceKey] --config "CreateDemoConfigSample.json"

Supported regions

https://learn.microsoft.com/azure/ai-services/speech-service/regions

Use region identifier for the region argument.

Create player configuration

Sample

{
  "DisplayName": "TTSPlayer",
  "Description": "Player for https://www.your-domain.com/path1/path2/",
  "TtsOutputFormat": "AUDIO-24KHZ-96KBITRATE-MONO-MP3",
  "Properties": {
    "PredefinedUrlPrefix": "https://www.your-domain.com/path1/path2/",
    "AllowedHtmlXPathList": [
      "//div[contains(@class, 'MSTTSPlayerContentSource')]"
    ],
    "AllowedVoiceNameList": [
      "en-US-GuyNeural"
    ],
    "AllowedVoiceStyleList": [
      "general",
      "newscast"
    ]
  }
}

Description

Property name Required Command line arguments
DisplayName Yes TTS player name
Description Yes TTS player description
TtsOutputFormat Yes TTS output format
PredefinedUrlPrefix Yes Your website root path
AllowedHtmlXPathList Yes Predefined html XPath allowed list, maximum 10 supported, only the XPath in this list can be used in synthesis API requset
AllowedVoiceNameList Yes Predefined voice name allowed list, maximum 100 supported, only the voice name in this list can be used in synthesis API requset, please go to [Voice Gallery] in speech portal to get voice name.
AllowedVoiceStyleList Yes Predefined voice style allowed list, including "general" style for default, maximum 100 supported, only the style in this list can be used in synthesis API requset, please go to [Voice Gallery] in speech portal to get supported styles of the voice.

Supported TtsOutputFormat

For now, only support: audio-24khz-96kbitrate-mono-mp3

After Feb in 2025, more formats will be supproted when create TTS player:

  • audio-16khz-32kbitrate-mono-mp3
  • audio-16khz-64kbitrate-mono-mp3
  • audio-16khz-128kbitrate-mono-mp3
  • audio-24khz-48kbitrate-mono-mp3
  • audio-24khz-96kbitrate-mono-mp3
  • audio-24khz-160kbitrate-mono-mp3
  • audio-48khz-96kbitrate-mono-mp3
  • audio-48khz-192kbitrate-mono-mp3

Create javascript client demo configuration

Sample

{
  "PlayerId": "BD6C1EA6-1D4C-4AA5-93F3-B0C50425A3CD",
  "ContentSourceLocation": "paht3/path4",
  "VoiceName": "en-US-GuyNeural",
  "VoiceStyle": "general",
  "HtmlXPathList": [
    "//div[contains(@class, 'MSTTSPlayerContentSource')]"
  ]
}

Description

Property name Command line arguments
PlayerId TTS player ID used for synthesis request.
ContentSourceLocation The webpage location used for synthesis request, for example if the value is paht3/path4, and the PredefinedUrlPrefix of player is https://www.your-domain.com/path1/path2/, then the player will synthesis web page https://www.your-domain.com/path1/path2/paht3/path4
VoiceName TTS voice name, the voice name need to be included in the AllowedVoiceNameList of the player
VoiceStyle TTS voice style name, the style name need to be included in the AllowedVoiceStyleList of the player
HtmlXPathList XPath list used for extracting plain text for TTS synthesizing, the xPath need to be included in the AllowedHtmlXPathList of the player

Advanced usage

For advanced usage, please contact admin:

  • For use custom neural voic in TTS player.
  • For synthesis SSML customization, like using custom lexcion, etc.

About

TTS player to synthesis webpage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published