SpeechSynthesisStream 클래스

정의

음성 합성 엔진(음성)이 임의 액세스 스트림에서 생성한 오디오 데이터를 읽고 쓸 수 있도록 지원합니다.

public ref class SpeechSynthesisStream sealed : IClosable
public ref class SpeechSynthesisStream sealed : IClosable, ITimedMetadataTrackProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class SpeechSynthesisStream final : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class SpeechSynthesisStream final : IClosable, ITimedMetadataTrackProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class SpeechSynthesisStream : System.IDisposable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class SpeechSynthesisStream : System.IDisposable, ITimedMetadataTrackProvider
Public NotInheritable Class SpeechSynthesisStream
Implements IDisposable
Public NotInheritable Class SpeechSynthesisStream
Implements IDisposable, ITimedMetadataTrackProvider
상속
Object Platform::Object IInspectable SpeechSynthesisStream
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

UWP 앱은 SpeechSynthesizer 개체를 사용하여 일반 텍스트 문자열을 기반으로 오디오 스트림 및 출력 음성을 만들 수 있습니다.

// The media object for controlling and playing audio.
MediaElement mediaElement = this.media;

// The object for controlling the speech synthesis engine (voice).
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

// Generate the audio stream from plain text.
SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Hello World");

// Send the stream to the media object.
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();
// The object for controlling the speech synthesis engine (voice).
synth = ref new SpeechSynthesizer();
// The media object for controlling and playing audio.
media = ref new MediaElement();
// The string to speak.
String^ text = "Hello World";

// Generate the audio stream from plain text.
task<SpeechSynthesisStream ^> speakTask = create_task(synth->SynthesizeTextToStreamAsync(text));
speakTask.then([this, text](SpeechSynthesisStream ^speechStream)
{
    // Send the stream to the media object.
    // media === MediaElement XAML object.
    media->SetSource(speechStream, speechStream->ContentType);
    media->AutoPlay = true;
    media->Play();
});
// The string to speak with SSML customizations.
string Ssml =
    @"<speak version='1.0' " +
    "xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'>" +
    "Hello <prosody contour='(0%,+80Hz) (10%,+80%) (40%,+80Hz)'>World</prosody> " + 
    "<break time='500ms'/>" +
    "Goodbye <prosody rate='slow' contour='(0%,+20Hz) (10%,+30%) (40%,+10Hz)'>World</prosody>" +
    "</speak>";

// The media object for controlling and playing audio.
MediaElement mediaElement = this.media;

// The object for controlling the speech synthesis engine (voice).
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

// Generate the audio stream from plain text.
SpeechSynthesisStream stream = await synth.synthesizeSsmlToStreamAsync(Ssml);

// Send the stream to the media object.
mediaElement.SetSource(stream, stream.ContentType);
mediaElement.Play();
// The object for controlling the speech synthesis engine (voice).
synth = ref new SpeechSynthesizer();
// The media object for controlling and playing audio.
media = ref new MediaElement();
// The string to speak.
String^ ssml =
    "<speak version='1.0' "
    "xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'>"
    "Hello <prosody contour='(0%,+80Hz) (10%,+80%) (40%,+80Hz)'>World</prosody>"
    "<break time='500ms' /> "
    "Goodbye <prosody rate='slow' contour='(0%,+20Hz) (10%,+30%) (40%,+10Hz)'>World</prosody>"
    "</speak>";

// Generate the audio stream from SSML.
task<SpeechSynthesisStream ^> speakTask = create_task(synth->SynthesizeSsmlToStreamAsync(ssml));
speakTask.then([this, ssml](SpeechSynthesisStream ^speechStream)
{
    // Send the stream to the media object.
    // media === MediaElement XAML object.
    media->SetSource(speechStream, speechStream->ContentType);
    media->AutoPlay = true;
    media->Play();
});

설명

버전 기록

Windows 버전 SDK 버전 추가된 값
1703 15063 TimedMetadataTracks

속성

CanRead

SpeechSynthesisStream을 읽을 수 있는지 여부를 가져옵니다.

CanWrite

SpeechSynthesisStream을 쓸 수 있는지 여부를 나타내는 값을 가져옵니다.

ContentType

SpeechSynthesisStream 콘텐츠의 MIME 형식을 가져옵니다.

Markers

SpeechSynthesisStream과 연결된 타임라인 표식의 컬렉션을 가져옵니다.

참고

SpeechSynthesisStream.Markers는 더 이상 사용되지 않습니다. MediaPlayerElementMediaPlaybackItem 개체를 대신 사용하는 것이 좋습니다(SpeechSynthesizerOptions 개체의 IncludeSentenceBoundaryMetadataIncludeWordBoundaryMetadata 속성과 함께 사용).

Position

SpeechSynthesisStream 내의 현재 위치를 가져옵니다.

Size

SpeechSynthesisStream의 크기를 가져오거나 설정합니다.

TimedMetadataTracks

SpeechSynthesizer.Options 속성에 지정된 대로 음성 합성 스트림에서 선택적 단어 및 문장 경계의 컬렉션을 가져옵니다.

메서드

CloneStream()

원래 스트림과 동일한 바이트를 참조하는 SpeechSynthesisStream 의 복사본을 만듭니다.

Close()

SpeechSynthesisStream에서 노출되는 시스템 리소스를 해제합니다.

Dispose()

관리되지 않는 리소스의 확보, 해제 또는 다시 설정과 관련된 애플리케이션 정의 작업을 수행합니다.

FlushAsync()

순차 스트림에서 데이터를 비동기적으로 플러시합니다.

GetInputStreamAt(UInt64)

SpeechSynthesisStream의 지정된 위치에서 입력 스트림을 검색합니다.

GetOutputStreamAt(UInt64)

SpeechSynthesisStream의 지정된 위치에서 출력 스트림을 검색합니다.

ReadAsync(IBuffer, UInt32, InputStreamOptions)

순차 스트림에서 데이터를 비동기적으로 읽습니다.

Seek(UInt64)

SpeechSynthesisStream 내에서 지정된 위치로 이동합니다.

WriteAsync(IBuffer)

순차 스트림에 데이터를 비동기적으로 씁니다.

적용 대상

추가 정보