Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New voices #16

Merged
merged 3 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions samples/YaCloudKit.TTS.Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
const string fileName = "tts_test.mp3";

// Yandex.Cloud return request id when LoggingEnabled = true
IYandexTts client = new YandexTtsClient(new YandexTtsConfig(apiKey) {LoggingEnabled = true});
IYandexTts client = new YandexTtsClient(new YandexTtsConfig(apiKey) { LoggingEnabled = true });

try
{
var result = await client.TextToSpeechAsync(text, VoiceParameters.Ermil, AudioFormat.Mp3);

Console.WriteLine("Status code: " + result.StatusCode);
Console.WriteLine("Request id: " + result.RequestId);

if (File.Exists(fileName))
File.Delete(fileName);

Expand All @@ -24,7 +24,6 @@
}
catch (YandexTtsServiceException e)
{

Console.WriteLine("Status code: " + e.StatusCode);
Console.WriteLine("Request id: " + e.RequestId);
Console.WriteLine(e.Message);
Expand Down
2 changes: 1 addition & 1 deletion src/TextToSpeech/YaCloudKit.TTS/IRequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public interface IRequestContext
/// <param name="key">Ключ/имя параметра</param>
/// <param name="value">значение параметра</param>
/// <returns></returns>
IRequestContext AddParametr(string key, string value);
IRequestContext AddParameter(string key, string value);

/// <summary>
/// Добавить заголовок в словарь
Expand Down
6 changes: 3 additions & 3 deletions src/TextToSpeech/YaCloudKit.TTS/Model/VoiceEmotion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace YaCloudKit.TTS;

public class VoiceEmotion
{
public static readonly VoiceEmotion Neutral = new VoiceEmotion("neutral");
public static readonly VoiceEmotion Good = new VoiceEmotion("good");
public static readonly VoiceEmotion Evil = new VoiceEmotion("evil");
public static readonly VoiceEmotion Neutral = new("neutral");
public static readonly VoiceEmotion Good = new("good");
public static readonly VoiceEmotion Evil = new("evil");

public string Value { get; }

Expand Down
8 changes: 5 additions & 3 deletions src/TextToSpeech/YaCloudKit.TTS/Model/VoiceLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ namespace YaCloudKit.TTS;

public class VoiceLanguage
{
public static readonly VoiceLanguage Russian = new VoiceLanguage("ru-RU");
public static readonly VoiceLanguage Kazakh = new VoiceLanguage("kk-KK");
public static readonly VoiceLanguage English = new VoiceLanguage("en-US");
public static readonly VoiceLanguage Russian = new("ru-RU");
public static readonly VoiceLanguage Kazakh = new("kk-KK");
public static readonly VoiceLanguage English = new("en-US");
public static readonly VoiceLanguage German = new("de-DE");
public static readonly VoiceLanguage Uzbek = new("uz-UZ");

public string Value { get; }

Expand Down
22 changes: 13 additions & 9 deletions src/TextToSpeech/YaCloudKit.TTS/Model/VoiceName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ namespace YaCloudKit.TTS;

public class VoiceName
{
public static readonly VoiceName Alena = new VoiceName("alena");
public static readonly VoiceName Filipp = new VoiceName("filipp");
public static readonly VoiceName Jane = new VoiceName("jane");
public static readonly VoiceName Omazh = new VoiceName("omazh");
public static readonly VoiceName Zahar = new VoiceName("zahar");
public static readonly VoiceName Ermil = new VoiceName("ermil");
public static readonly VoiceName Amira = new VoiceName("amira");
public static readonly VoiceName John = new VoiceName("john");

public static readonly VoiceName Lea = new("lea");
public static readonly VoiceName Alena = new("alena");
public static readonly VoiceName Filipp = new("filipp");
public static readonly VoiceName Jane = new("jane");
public static readonly VoiceName Omazh = new("omazh");
public static readonly VoiceName Zahar = new("zahar");
public static readonly VoiceName Ermil = new("ermil");
public static readonly VoiceName Amira = new("amira");
public static readonly VoiceName John = new("john");
public static readonly VoiceName Madi = new("madi");
public static readonly VoiceName Madirus = new("madirus");
public static readonly VoiceName Nigora = new("nigora");

public string Value { get; }

public VoiceName(string value)
Expand Down
38 changes: 37 additions & 1 deletion src/TextToSpeech/YaCloudKit.TTS/Model/VoiceParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace YaCloudKit.TTS
/// </summary>
public class VoiceParameters
{
/// <summary>
/// Женский немецкий голос Lea
/// </summary>
public static readonly VoiceParameters Lea = new(VoiceName.Lea);

/// <summary>
/// Женский русский голос Alena
/// </summary>
Expand Down Expand Up @@ -37,6 +42,30 @@ public class VoiceParameters
/// </summary>
public static readonly VoiceParameters Ermil = new(VoiceName.Ermil);

/// <summary>
/// Женский казахский голос
/// </summary>
public static readonly VoiceParameters Amira = new(VoiceName.Amira);

/// <summary>
/// Мужской казахский голос
/// </summary>
public static readonly VoiceParameters Madi = new(VoiceName.Madi);

/// <summary>
/// Мужской английский голос
/// </summary>
public static readonly VoiceParameters John = new(VoiceName.John);

/// <summary>
/// Мужской русский голос
/// </summary>
public static readonly VoiceParameters Madirus = new(VoiceName.Madirus);

/// <summary>
/// Женский узбекский голос
/// </summary>
public static readonly VoiceParameters Nigora = new(VoiceName.Nigora);

/// <summary>
/// Название голоса. Подробнее см. список голосов
Expand Down Expand Up @@ -64,11 +93,18 @@ public class VoiceParameters
/// Инициалзация параметров голоса для генерации речи
/// </summary>
/// <param name="name">Название голоса</param>
public VoiceParameters(VoiceName name)
public VoiceParameters(
VoiceName name,
VoiceLanguage language = null,
string speed = null,
VoiceEmotion emotion = null)
{
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentNullException(nameof(name));
Name = name;
Language = language;
Speed = speed;
Emotion = emotion;
}
}
}
2 changes: 1 addition & 1 deletion src/TextToSpeech/YaCloudKit.TTS/RequestContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public RequestContext(IDictionary<string, string> requestParameters, IDictionary
Headers = headers ?? throw new ArgumentNullException(nameof(headers));
}

public IRequestContext AddParametr(string key, string value)
public IRequestContext AddParameter(string key, string value)
{
if (string.IsNullOrWhiteSpace(key))
throw new ArgumentNullException(nameof(key));
Expand Down
16 changes: 8 additions & 8 deletions src/TextToSpeech/YaCloudKit.TTS/Utils/RequestParametersHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ public static void AddTextParam(IRequestContext context, string text, bool ssml)
throw new ArgumentOutOfRangeException(nameof(text),
"The maximum text length must not exceed 5000 characters");

context.AddParametr(ssml ? "ssml" : "text", text);
context.AddParameter(ssml ? "ssml" : "text", text);
}

public static void AddVoiceParam(IRequestContext context, VoiceParameters voice)
{
if (voice == null)
throw new ArgumentNullException(nameof(voice));

context.AddParametr("voice", voice.Name);
context.AddParameter("voice", voice.Name);

if (voice.Language is not null)
context.AddParametr("lang", voice.Language);
context.AddParameter("lang", voice.Language);
if (voice.Emotion is not null)
context.AddParametr("emotion", voice.Emotion);
context.AddParameter("emotion", voice.Emotion);
if (voice.Emotion is not null)
context.AddParametr("speed", voice.Speed);
context.AddParameter("speed", voice.Speed);
}

public static void AddFormatParam(IRequestContext context, AudioFormat format)
{
if (format == null || string.IsNullOrWhiteSpace(format.Format))
throw new ArgumentException(nameof(format));

context.AddParametr("format", format.Format);
context.AddParameter("format", format.Format);
if (format.SampleRateHertz.HasValue)
context.AddParametr("sampleRateHertz", format.SampleRateHertz.ToString());
context.AddParameter("sampleRateHertz", format.SampleRateHertz.ToString());
}

public static void AddFolderParam(IRequestContext context, YandexTtsConfig config)
Expand All @@ -49,7 +49,7 @@ public static void AddFolderParam(IRequestContext context, YandexTtsConfig confi
if (string.IsNullOrWhiteSpace(config.FolderID))
throw new ArgumentNullException(nameof(config.FolderID));

context.AddParametr("folderId", config.FolderID);
context.AddParameter("folderId", config.FolderID);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/TextToSpeech/YaCloudKit.TTS/YaCloudKit.TTS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageIcon>logo-main.png</PackageIcon>
<VersionMajor>0</VersionMajor>
<VersionMinor>3</VersionMinor>
<BuildNumber>9</BuildNumber>
<VersionMinor>4</VersionMinor>
<BuildNumber>0</BuildNumber>
<PackageVersion>$(VersionMajor).$(VersionMinor).$(BuildNumber)$(VersionTag)</PackageVersion>
<AssemblyVersion>$(VersionMajor).$(VersionMinor).$(BuildNumber)$(VersionTag)</AssemblyVersion>
<FileVersion>$(VersionMajor).$(VersionMinor).$(BuildNumber)$(VersionTag)</FileVersion>
Expand Down
Loading