SpeechAudioFormatInfo Constructors

Definition

Initializes a new instance of the SpeechAudioFormatInfo class.

Overloads

SpeechAudioFormatInfo(Int32, AudioBitsPerSample, AudioChannel)

Initializes a new instance of the SpeechAudioFormatInfo class and specifies the samples per second, bits per sample, and the number of channels.

SpeechAudioFormatInfo(EncodingFormat, Int32, Int32, Int32, Int32, Int32, Byte[])

Initializes a new instance of the SpeechAudioFormatInfo class and specifies the encoding format, samples per second, bits per sample, number of channels, average bytes per second, block alignment value, and an array containing format-specific data.

SpeechAudioFormatInfo(Int32, AudioBitsPerSample, AudioChannel)

Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs

Initializes a new instance of the SpeechAudioFormatInfo class and specifies the samples per second, bits per sample, and the number of channels.

C#
public SpeechAudioFormatInfo(int samplesPerSecond, System.Speech.AudioFormat.AudioBitsPerSample bitsPerSample, System.Speech.AudioFormat.AudioChannel channel);

Parameters

samplesPerSecond
Int32

The value for the samples per second.

bitsPerSample
AudioBitsPerSample

The value for the bits per sample.

channel
AudioChannel

A member of the AudioChannel enumeration (indicating Mono or Stereo).

Examples

The following example shows a typical use of SpeechAudioFormatInfo to specify the format of audio to output to a WAV file. The SpeechAudioFormatInfo instance is an argument to the SetOutputToWaveFile method.

C#
using System;  
using System.IO;  
using System.Speech.Synthesis;  
using System.Speech.AudioFormat;  

namespace SampleSynthesis  
{  
  class Program  
  {  
    static void Main(string[] args)  
    {  

      // Initialize a new instance of the SpeechSynthesizer.  
      using (SpeechSynthesizer synth = new SpeechSynthesizer())  
      {  

        // Configure the audio output.   
        synth.SetOutputToWaveFile(@"C:\temp\test.wav",   
          new SpeechAudioFormatInfo(32000, AudioBitsPerSample.Sixteen, AudioChannel.Mono));  

        // Create a SoundPlayer instance to play output audio file.  
        System.Media.SoundPlayer m_SoundPlayer =   
          new System.Media.SoundPlayer(@"C:\temp\test.wav");  

        // Build a prompt.  
        PromptBuilder builder = new PromptBuilder();  
        builder.AppendText("This is sample output to a WAVE file.");  

        // Speak the prompt.  
        synth.Speak(builder);  
        m_SoundPlayer.Play();  
      }  

      Console.WriteLine();  
      Console.WriteLine("Press any key to exit...");  
      Console.ReadKey();  
    }  
  }  
}  

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

SpeechAudioFormatInfo(EncodingFormat, Int32, Int32, Int32, Int32, Int32, Byte[])

Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs
Source:
SpeechAudioFormatInfo.cs

Initializes a new instance of the SpeechAudioFormatInfo class and specifies the encoding format, samples per second, bits per sample, number of channels, average bytes per second, block alignment value, and an array containing format-specific data.

C#
public SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat encodingFormat, int samplesPerSecond, int bitsPerSample, int channelCount, int averageBytesPerSecond, int blockAlign, byte[] formatSpecificData);

Parameters

encodingFormat
EncodingFormat

The encoding format.

samplesPerSecond
Int32

The value for the samples per second.

bitsPerSample
Int32

The value for the bits per sample.

channelCount
Int32

The value for the channel count.

averageBytesPerSecond
Int32

The value for the average bytes per second.

blockAlign
Int32

The value for the BlockAlign.

formatSpecificData
Byte[]

A byte array containing the format-specific data.

Applies to

.NET 10 (package-provided) and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)