Created
May 24, 2020 07:51
-
-
Save buchizo/d61b4301851bb7414b1dcbcf7179d0ae to your computer and use it in GitHub Desktop.
neural TTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.CognitiveServices.Speech; | |
using System; | |
using System.Threading.Tasks; | |
namespace ConsoleApp15 | |
{ | |
class Program | |
{ | |
private static readonly string ApiKey = "xxxxxxxxxxxxxxxxxxxxxxxx"; | |
static async Task Main(string[] args) | |
{ | |
Cocona.CoconaApp.Run<Program>(args); | |
} | |
public async Task Normal() | |
{ | |
var config = SpeechConfig.FromSubscription(ApiKey, "eastus"); | |
config.SpeechSynthesisLanguage = "ja-JP"; | |
config.SpeechSynthesisVoiceName = "ja-JP-HarukaRUS"; | |
var speaker = new SpeechSynthesizer(config); | |
Console.Write("input text: "); | |
var text = Console.ReadLine(); | |
var result = await speaker.SpeakTextAsync(text); | |
if (result.Reason == ResultReason.SynthesizingAudioCompleted) | |
{ | |
Console.WriteLine("end"); | |
} | |
else if (result.Reason == ResultReason.Canceled) | |
{ | |
var cancellation = SpeechSynthesisCancellationDetails.FromResult(result); | |
Console.WriteLine(cancellation.ErrorDetails); | |
} | |
} | |
public async Task Neural() | |
{ | |
var config = SpeechConfig.FromSubscription(ApiKey, "eastus"); | |
config.SpeechSynthesisLanguage = "ja-JP"; | |
config.SpeechSynthesisVoiceName = "ja-JP-NanamiNeural"; | |
var speaker = new SpeechSynthesizer(config); | |
Console.Write("input text: "); | |
var text = Console.ReadLine(); | |
var result = await speaker.SpeakTextAsync(text); | |
if (result.Reason == ResultReason.SynthesizingAudioCompleted) | |
{ | |
Console.WriteLine("end"); | |
} | |
else if (result.Reason == ResultReason.Canceled) | |
{ | |
var cancellation = SpeechSynthesisCancellationDetails.FromResult(result); | |
Console.WriteLine(cancellation.ErrorDetails); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment