Beispiel #1
0
        public static void NamedAttributes(IRequestContext context, Dictionary <string, string> values)
        {
            var number = 1;

            foreach (var item in values)
            {
                context.AddParametr($"Attribute.{number}.Name", item.Key);
                context.AddParametr($"Attribute.{number}.Value", item.Value);
                number++;
            }
        }
        public static void AddFormatParam(IRequestContext context, FormatParameters format)
        {
            if (format == null || string.IsNullOrWhiteSpace(format.Format))
            {
                throw new ArgumentNullException(nameof(format));
            }

            context.AddParametr("format", format.Format);
            if (format.SampleRateHertz.HasValue)
            {
                context.AddParametr("sampleRateHertz", format.SampleRateHertz.ToString());
            }
        }
        public static void AddVoiceParam(IRequestContext context, VoiceParameters voice)
        {
            if (voice == null || !voice.IsSetParam())
            {
                throw new ArgumentException(nameof(voice));
            }

            context.AddParametr("lang", voice.Language);
            context.AddParametr("voice", voice.Name);
            if (!string.IsNullOrWhiteSpace(voice.Emotion))
            {
                context.AddParametr("emotion", voice.Emotion);
            }
            if (!string.IsNullOrWhiteSpace(voice.Emotion))
            {
                context.AddParametr("speed", voice.Speed);
            }
        }
Beispiel #4
0
        public static void ListMessageAttributes(IRequestContext context, List <string> values)
        {
            var number = 1;

            foreach (var item in values)
            {
                context.AddParametr($"MessageAttributeName.{number}", item);
                number++;
            }
        }
        public static void AddTextParam(IRequestContext context, string text, bool ssml)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (text.Length > 5000)
            {
                throw new ArgumentOutOfRangeException(nameof(text), "Максимальная длина текста не должна превышать 5000 символов");
            }

            context.AddParametr(ssml ? "ssml" : "text", text);
        }
Beispiel #6
0
        public static void MessageAttributesBatchEntry(int entryNumber, IRequestContext context, Dictionary <string, MessageAttributeValue> values)
        {
            var number = 1;

            foreach (var item in values)
            {
                if (item.Value.IsSetValue())
                {
                    context.AddParametr($"SendMessageBatchRequestEntry.{entryNumber}.MessageAttribute.{number}.Name", item.Key);
                    context.AddParametr($"SendMessageBatchRequestEntry.{entryNumber}.MessageAttribute.{number}.Value.DataType", item.Value.DataType.ToString());
                    switch (item.Value.DataType)
                    {
                    case AttributeValueType.Binary:
                        context.AddParametr($"SendMessageBatchRequestEntry.{entryNumber}.MessageAttribute.{number}.Value.BinaryValue", Convert.ToBase64String(item.Value.BinaryValue));
                        break;

                    default:
                        context.AddParametr($"SendMessageBatchRequestEntry.{entryNumber}.MessageAttribute.{number}.Value.StringValue", item.Value.StringValue);
                        break;
                    }
                }
                number++;
            }
        }
        public static void AddFolderParam(IRequestContext context, YandexTtsConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (!string.IsNullOrWhiteSpace(config.TokenIAM))
            {
                if (string.IsNullOrWhiteSpace(config.FolderID))
                {
                    throw new ArgumentNullException(nameof(config.FolderID));
                }

                context.AddParametr("folderId", config.FolderID);
            }
        }