Ejemplo n.º 1
0
        /// <summary>
        /// Produces the SAPI "RATE" tag
        /// </summary>
        private static int SapiRate(ProsodyNumber rate)
        {
            // Okay, we have a RATE element, but what do we set the rate to?
            // Rate varies on a scale from -10 to 10 for us.
            // There isn't a defined mapping between Words per Minute and rate.
            // For percentage changes, we will require that -10 maps to one third the default rate,
            // and +10 to three times the default, on a log scale.
            // But for absolute or relative (not percent) we can't support this without a defined base-line rate
            // We could get away with 180 for this in English, but very variable across languages.

            int sapiRate = 0;

            if (rate.SsmlAttributeId != ProsodyNumber.AbsoluteNumber)
            {
                switch ((ProsodyRate)rate.SsmlAttributeId)
                {
                case ProsodyRate.ExtraSlow:
                    sapiRate = -9;
                    break;

                case ProsodyRate.Slow:
                    sapiRate = -4;
                    break;

                case ProsodyRate.Fast:
                    sapiRate = 4;
                    break;

                case ProsodyRate.ExtraFast:
                    sapiRate = 9;
                    break;
                }

                // add the relative information
                sapiRate = (int)((rate.IsNumberPercent ? ScaleNumber(rate.Number, sapiRate, 10) : sapiRate) + 0.5);
            }
            else
            {
                sapiRate = ScaleNumber(rate.Number, 0, 10);
            }
            // Check the range.
            if (sapiRate > 10)
            {
                sapiRate = 10;
            }
            if (sapiRate < -10)
            {
                sapiRate = -10;
            }
            return(sapiRate);
        }
Ejemplo n.º 2
0
        private static int SapiVolume(ProsodyNumber volume)
        {
            int sapiVolume = 100;

            if (volume.SsmlAttributeId != ProsodyNumber.AbsoluteNumber)
            {
                switch ((ProsodyVolume)volume.SsmlAttributeId)
                {
                case ProsodyVolume.ExtraLoud:
                    sapiVolume = 100;
                    break;

                case ProsodyVolume.Loud:
                    sapiVolume = 80;
                    break;

                case ProsodyVolume.Medium:
                    sapiVolume = 60;
                    break;

                case ProsodyVolume.Soft:
                    sapiVolume = 40;
                    break;

                case ProsodyVolume.ExtraSoft:
                    sapiVolume = 20;
                    break;

                case ProsodyVolume.Silent:
                    sapiVolume = 0;
                    break;
                }
                // add the relative information
                sapiVolume = (int)((volume.IsNumberPercent ? sapiVolume * volume.Number : volume.Number) + 0.5);
            }
            else
            {
                sapiVolume = (int)(volume.Number + 0.5);
            }

            // Check the range.
            if (sapiVolume > 100)
            {
                sapiVolume = 100;
            }
            if (sapiVolume < 0)
            {
                sapiVolume = 0;
            }
            return(sapiVolume);
        }
Ejemplo n.º 3
0
        private static int SapiVolume(ProsodyNumber volume)
        {
            int num = 100;

            if (volume.SsmlAttributeId != int.MaxValue)
            {
                switch (volume.SsmlAttributeId)
                {
                case -7:
                    num = 100;
                    break;

                case -6:
                    num = 80;
                    break;

                case -5:
                    num = 60;
                    break;

                case -4:
                    num = 40;
                    break;

                case -3:
                    num = 20;
                    break;

                case -2:
                    num = 0;
                    break;
                }
                num = (int)((double)(volume.IsNumberPercent ? ((float)num * volume.Number) : volume.Number) + 0.5);
            }
            else
            {
                num = (int)((double)volume.Number + 0.5);
            }
            if (num > 100)
            {
                num = 100;
            }
            if (num < 0)
            {
                num = 0;
            }
            return(num);
        }
Ejemplo n.º 4
0
        private static int SapiRate(ProsodyNumber rate)
        {
            int num = 0;

            if (rate.SsmlAttributeId != int.MaxValue)
            {
                switch (rate.SsmlAttributeId)
                {
                case 1:
                    num = -9;
                    break;

                case 2:
                    num = -4;
                    break;

                case 4:
                    num = 4;
                    break;

                case 5:
                    num = 9;
                    break;
                }
                num = (int)((double)(rate.IsNumberPercent ? ScaleNumber(rate.Number, num, 10) : num) + 0.5);
            }
            else
            {
                num = ScaleNumber(rate.Number, 0, 10);
            }
            if (num > 10)
            {
                num = 10;
            }
            if (num < -10)
            {
                num = -10;
            }
            return(num);
        }
Ejemplo n.º 5
0
        private static int SapiPitch(ProsodyNumber pitch)
        {
            int sapiPitch = 0;

            if (pitch.SsmlAttributeId != ProsodyNumber.AbsoluteNumber)
            {
                switch ((ProsodyPitch)pitch.SsmlAttributeId)
                {
                case ProsodyPitch.ExtraHigh:
                    sapiPitch = 9;
                    break;

                case ProsodyPitch.High:
                    sapiPitch = 4;
                    break;

                case ProsodyPitch.Low:
                    sapiPitch = -4;
                    break;

                case ProsodyPitch.ExtraLow:
                    sapiPitch = -9;
                    break;
                }
                // add the relative information
                sapiPitch = (int)((pitch.IsNumberPercent ? sapiPitch * pitch.Number : pitch.Number) + 0.5);
            }

            // Check the range.
            if (sapiPitch > 10)
            {
                sapiPitch = 10;
            }
            if (sapiPitch < -10)
            {
                sapiPitch = -10;
            }
            return(sapiPitch);
        }
Ejemplo n.º 6
0
        private static int SapiPitch(ProsodyNumber pitch)
        {
            int num = 0;

            if (pitch.SsmlAttributeId != int.MaxValue)
            {
                switch (pitch.SsmlAttributeId)
                {
                case 5:
                    num = 9;
                    break;

                case 4:
                    num = 4;
                    break;

                case 2:
                    num = -4;
                    break;

                case 1:
                    num = -9;
                    break;
                }
                num = (int)((double)(pitch.IsNumberPercent ? ((float)num * pitch.Number) : pitch.Number) + 0.5);
            }
            if (num > 10)
            {
                num = 10;
            }
            if (num < -10)
            {
                num = -10;
            }
            return(num);
        }