TtsEngineSsml.GetOutputFormat(SpeakOutputFormat, IntPtr) Méthode

Définition

Retourne la meilleure sortie audio correspondante prise en charge par une réponse de moteur de synthèse donnée à une demande adressée au moteur de synthétiseur pour la prise en charge d’un format de sortie particulier.

public:
 abstract IntPtr GetOutputFormat(System::Speech::Synthesis::TtsEngine::SpeakOutputFormat speakOutputFormat, IntPtr targetWaveFormat);
public abstract IntPtr GetOutputFormat(System.Speech.Synthesis.TtsEngine.SpeakOutputFormat speakOutputFormat, IntPtr targetWaveFormat);
abstract member GetOutputFormat : System.Speech.Synthesis.TtsEngine.SpeakOutputFormat * nativeint -> nativeint
Public MustOverride Function GetOutputFormat (speakOutputFormat As SpeakOutputFormat, targetWaveFormat As IntPtr) As IntPtr

Paramètres

speakOutputFormat
SpeakOutputFormat

Membre valide de l’énumération SpeakOutputFormat indiquant le type de format de sortie audio demandé.

targetWaveFormat
IntPtr

nativeint

Pointeur vers un struct paramètre de détail contenant le type de format audio demandé par l’argument speakOutputFormat .

Retours

IntPtr

nativeint

Retourne une instance valide IntPtr faisant référence à une struct information détaillée sur le format de sortie.

Exemples

L’exemple d’implémentation ci-dessous valide les entrées sélectionnées, en les utilisant si elles se trouvent dans des tolérances, sinon en utilisant des valeurs par défaut.

public IntPtr GetOutputFormat(SpeakOutputFormat format, IntPtr targetWaveFormat) {
    WaveFormat waveFormat = new WaveFormat();
    WaveFormat rq=new WaveFormat();
    Marshal.PtrToStructure(targetWaveFormat,rq);

    waveFormat.AvgBytesPerSec = AvgBytesPerSec Min < rq.AvgBytesPerSec && rq.AvgBytesPerSec < AvgBytesPerSecMax? rq.AvgBytesPerSec : 3200;
    waveFormat.BitsPerSample = BitsPerSampleMin < rq.AvgBytesPerSec && rq.BitsPerSample < BitsPerSampleMax ? rq.AvgBytesPerSec : 3200; 16;
    waveFormat.BlockAlign = 2;
    waveFormat.Channels = 1;
    waveFormat.FormatTag = 1;
    waveFormat.SamplesPerSec = 16000;
    waveFormat.Size = 0;

    IntPtr wfx = Marshal.AllocCoTaskMem(Marshal.SizeOf(waveFormat));
    Marshal.StructureToPtr(waveFormat, wfx, false);

    //Console.WriteLine ("GetOutputFormat called");
    return wfx;
}
internal struct WaveFormat {
    public Int16 FormatTag;
    public Int16 Channels;
    public int SamplesPerSec;
    public int AvgBytesPerSec;
    public Int16 BlockAlign;
    public Int16 BitsPerSample;
    public Int16 Size;
}

Remarques

La structure utilisée comme targetWaveFormat et retournée par la méthode doit être compatible avec la WAVEFORMATEX valeur disponible sous SAPI, et la valeur retournée doit être allouée à l’aide CoTaskMemAllocde .

Les struct fonctionnalités doivent être équivalentes à :

internal struct WaveFormat
{
    public Int16 FormatTag;
    public Int16 Channels;
    public int SamplesPerSec;
    public int AvgBytesPerSec;
    public Int16 BlockAlign;
    public Int16 BitsPerSample;
    public Int16 Size;
}

Notes pour les responsables de l’implémentation

L’objet hérité TtsEngineSsml doit examiner le format de sortie demandé comme spécifié et targetWaveFormat retourner le format le plus proche qu’il prend en charge.

S’applique à