Class: shaka.text.SpeechToText

Constructor

new SpeechToText(player)

Parameters:
Name Type Description
player shaka.Player
Implements:
Source:

Members

audioObjectMap_ :Map<!HTMLMediaElement, shaka.text.SpeechToText.AudioObject>

For now, we never clean this up because if we close the context and disconnect from the source, the audio from the video element never works again.
Type:
Source:

isMediaStreamTrackSupported :shaka.util.Lazy<boolean>

Type:
Source:

activeTrackId_ :number

Type:
  • number
Source:

enabled_ :boolean

Type:
  • boolean
Source:

needTranslator_ :boolean

Type:
  • boolean
Source:

nextTextTrackId_ :number

Type:
  • number
Source:

recognition_ :ChromeSpeechRecognition

Type:
  • ChromeSpeechRecognition
Source:

supported_ :boolean

Type:
  • boolean
Source:

textContainer_ :HTMLElement

Type:
  • HTMLElement
Source:

translator_ :Translator

Type:
  • Translator
Source:

translatorAbortController_ :AbortController

Type:
  • AbortController
Source:

Methods

checkTextTrackChanges_()

Source:

configure(config)

Parameters:
Name Type Description
config shaka.extern.SpeechToTextConfiguration
Source:

createTextTrack_() → {shaka.extern.TextTrack}

Source:
Returns:
Type
shaka.extern.TextTrack

disable()

Disable speech to text.
Source:

enable(tracknon-null)

Enable speech to text.
Parameters:
Name Type Description
track shaka.extern.TextTrack
Source:

getAudioTrackFromMediaElement_() → {MediaStreamTrack}

Source:
Returns:
Type
MediaStreamTrack

getTextContainer_() → {HTMLElement}

Source:
Returns:
Type
HTMLElement

getTextTracks() → {Array<shaka.extern.TextTrack>}

Source:
Returns:
Type
Array<shaka.extern.TextTrack>

initRecognition_(mediaStreamTracknon-null, sourceLanguage, targetLanguage)

Parameters:
Name Type Description
mediaStreamTrack MediaStreamTrack
sourceLanguage string
targetLanguage string
Source:

isEnabled() → {boolean}

Source:
Returns:
Type
boolean

isSupported() → {boolean}

Source:
Returns:
Type
boolean

onAudioTrackChange_()

Source:

release()

Request that this object release all internal references.
Implements:
Source:

removeRenderedText_()

Source:

setupTranslator_(sourceLanguage, targetLanguage) → {Promise}

Parameters:
Name Type Description
sourceLanguage string
targetLanguage string
Source:
Returns:
Type
Promise

stopRecognition_(removeRenderedopt)

Parameters:
Name Type Attributes Default Description
removeRendered boolean <optional>
true
Source:

truncateLastWords_(text, limit) → {string}

Truncates a string to the last `limit` characters, ensuring that only complete words are included. If a word is cut at the limit, it is included in full. Adds '...' at the start if truncation occurs.
Parameters:
Name Type Description
text string The input string to truncate.
limit number The maximum number of characters to consider from the end of the string.
Source:
Returns:
The truncated string, starting at the first complete word within the limit, and prefixed with '...' if truncation was applied.
Type
string

Type Definitions

AudioObject

Type:
  • {audioContext: AudioContext, sourceNode: MediaElementAudioSourceNode, destinationNode: MediaStreamAudioDestinationNode, audioTrack: MediaStreamTrack}
Source: