Skip to content

Commit

Permalink
Исправления
Browse files Browse the repository at this point in the history
  • Loading branch information
gkurbesov committed Mar 24, 2024
1 parent 3ff4d5d commit c37427d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
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
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

0 comments on commit c37427d

Please sign in to comment.