Preparing search index...

    Class TextToSpeechModule

    Allows generation of audio from a given text with a variety of options.

    You can use only one TextToSpeechModule in a Lens. However, its methods can be called multiple times in parallel if needed.

    VoiceML capabilities are no longer supported. For Spectacles see options on ASRModule.

    Lens Scripting Version 158

    Since Lens Scripting Version 348

    //@input Asset.TextToSpeechModule textToSpeech

    var onTTSErrorHandler = function(error, description){
    print('error: ' + error + " desc: " + description);
    }

    var onTTSCompleteHandler = function(audioTrackAsset, wordInfos){
    var additionalInformation = "Successfully synthesized audio\n\n";
    var wordInfosTxt = "Word Infos:";
    for (var i = 0; i < wordInfos.length; i++) {
    wordInfosTxt += "\nWord: '" + wordInfos[i].word + "', startTime: " + wordInfos[i].startTime.toString() + ", endTime: " + wordInfos[i].endTime.toString();
    }
    print(additionalInformation + wordInfosTxt);
    var audioComponent = script.getSceneObject().createComponent('Component.AudioComponent');
    audioComponent.audioTrack = audioTrackAsset;
    audioComponent.play(1);
    }

    script.textToSpeech.synthesize("show me you love cats, without telling me you love cats!" , TextToSpeech.Options.create(), onTTSCompleteHandler, onTTSErrorHandler);

    Hierarchy (View Summary)

    Index

    Properties

    name: string

    The name of the Asset in Lens Studio.

    ""
    
    uniqueIdentifier: string

    Lens Scripting Version 176

    Methods

    • Returns the name of this object's type.

      Returns string

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean