FilePrompt Constructors

Definition

Creates a new instance of the FilePrompt class.

Overloads

FilePrompt(String, SynthesisMediaType)

Creates a new instance of the FilePrompt class, and specifies the path to the file and its media type.

FilePrompt(Uri, SynthesisMediaType)

Creates a new instance of the FilePrompt class, and specifies the location of the file and its media type.

FilePrompt(String, SynthesisMediaType)

Source:
FilePrompt.cs
Source:
FilePrompt.cs

Creates a new instance of the FilePrompt class, and specifies the path to the file and its media type.

public FilePrompt (string path, System.Speech.Synthesis.SynthesisMediaType media);

Parameters

path
String

The path of the file containing the prompt content.

media
SynthesisMediaType

The media type of the file.

Examples

The example that follows creates a FilePrompt object that specifies a path to an SSML prompt. To speak the contents of the prompt, the example then provides the FilePrompt object as the argument to the Speak method.

using System;  
using System.Speech.Synthesis;  

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.SetOutputToDefaultAudioDevice();  

                // Create a FilePrompt object that references an SSML prompt.  
                FilePrompt ssmlFile = new FilePrompt("c:\\test\\Weather.ssml", SynthesisMediaType.Ssml);  

                // Speak the contents of the SSML prompt.  
                synth.Speak(ssmlFile);  
            }  

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

The following is the SSML file that the preceding example references.

<?xml version="1.0" encoding="ISO-8859-1"?>  
<speak version="1.0"  
 xmlns="http://www.w3.org/2001/10/synthesis"  
 xml:lang="en-US">  

  <s> The weather forecast for today is partly cloudy with some sun breaks. </s>  

</speak>  

Remarks

You can use this class to create an object from an existing Speech Synthesis Markup Language (SSML) file that the SpeechSynthesizer can consume to generate speech.

Applies to

.NET 9 (package-provided) и другие версии
Продукт Версии
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)

FilePrompt(Uri, SynthesisMediaType)

Source:
FilePrompt.cs
Source:
FilePrompt.cs

Creates a new instance of the FilePrompt class, and specifies the location of the file and its media type.

public FilePrompt (Uri promptFile, System.Speech.Synthesis.SynthesisMediaType media);

Parameters

promptFile
Uri

The URI of the file containing the prompt content.

media
SynthesisMediaType

The media type of the file.

Applies to

.NET 9 (package-provided) и другие версии
Продукт Версии
.NET 6 (package-provided), 7 (package-provided), 8 (package-provided), 9 (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 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)