New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AX: Consider VTT-based audio descriptions with text-to-speech. #3486
AX: Consider VTT-based audio descriptions with text-to-speech. #3486
Conversation
EWS run on previous version of this PR (hash 4ea8460) |
4ea8460
to
cd29f04
Compare
cd29f04
to
dfb23ea
Compare
EWS run on previous version of this PR (hash dfb23ea)
|
dfb23ea
to
361d3b7
Compare
EWS run on previous version of this PR (hash 361d3b7)
|
361d3b7
to
22b2f19
Compare
EWS run on previous version of this PR (hash 22b2f19)
|
22b2f19
to
847fe9e
Compare
EWS run on previous version of this PR (hash 847fe9e)
|
847fe9e
to
acee957
Compare
EWS run on previous version of this PR (hash acee957)
|
acee957
to
46e92dc
Compare
EWS run on previous version of this PR (hash 46e92dc)
|
|
||
auto exitEvent = Event::create(eventNames().exitEvent, Event::CanBubble::No, Event::IsCancelable::No); | ||
scheduleEventOn(*eventTask.second, WTFMove(exitEvent)); | ||
executeCueEnterOrLeaveAction(*eventTask.second, CueAction::Enter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It might be cleaner to make eventTask
a structured binding auto& [eventTime, eventCue]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, we should do that as a followup.
if (!m_cueBeingSpoken) | ||
return false; | ||
|
||
ALWAYS_LOG(LOGIDENTIFIER, "time = ", time, ", returning ", (time.toDouble() >= m_cueBeingSpoken->startTime() && time.toDouble() < m_cueBeingSpoken->endTime())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(time.toDouble() >= m_cueBeingSpoken->startTime() && time.toDouble() < m_cueBeingSpoken->endTime())
can be its own variable like timeIsInRange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll change that.
Source/WebCore/html/track/VTTCue.cpp
Outdated
return; | ||
|
||
auto& track = *this->track(); | ||
if (!m_speechUtterance) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for m_speechUtterance
to exist at this point? If so, the completion handler won't be called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't be possible, I'll add an assert and will remove the test.
46e92dc
to
2afe52d
Compare
|
https://bugs.webkit.org/show_bug.cgi?id=243600 rdar://98206665 Reviewed by Jer Noble. * LayoutTests/media/track/captions-webvtt/captions-descriptions.vtt: Added. * LayoutTests/media/track/track-description-cue-expected.txt: Added. * LayoutTests/media/track/track-description-cue.html: Added. * LayoutTests/TestExpectations: Feature is Cocoa-specific so far, skip test globally. * LayoutTests/platform/ios/TestExpectations: Enable test on iOS. * LayoutTests/platform/mac/TestExpectations: Enable test on macOS. * Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml: Add 'AudioDescriptionsEnabled' setting. * Source/WebCore/Modules/speech/SpeechSynthesis.cpp: (WebCore::SpeechSynthesis::handleSpeakingCompleted): Call utterance to fire event. (WebCore::SpeechSynthesis::boundaryEventOccurred): Ditto. (WebCore::SpeechSynthesis::didStartSpeaking): Ditto. (WebCore::SpeechSynthesis::didPauseSpeaking): Ditto. (WebCore::SpeechSynthesis::didResumeSpeaking): Ditto. (WebCore::SpeechSynthesis::fireEvent const): Deleted. (WebCore::SpeechSynthesis::fireErrorEvent const): Deleted. * Source/WebCore/Modules/speech/SpeechSynthesis.h: (WebCore::SpeechSynthesis::userGestureRequiredForSpeechStart const): (WebCore::SpeechSynthesis::removeBehaviorRestriction): Make public. * Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp: (WebCore::SpeechSynthesisUtterance::create): Add version that takes a completion handler. (WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance): Add completion handler parameter. (WebCore::SpeechSynthesisUtterance::eventOccurred): New. Call completion handler or dispatch event. (WebCore::SpeechSynthesisUtterance::errorEventOccurred): Ditto. * Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h: * Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl: JSGenerateToJSObject. * Source/WebCore/html/HTMLMediaElement.cpp: (WebCore::HTMLMediaElement::updateActiveTextTrackCues): Return early if a seek is pending. Call new executeCueEnterOrLeaveAction method instead of dispatching events directly. (WebCore::HTMLMediaElement::setSpeechSynthesisState): Maintain synthesis state. (WebCore::HTMLMediaElement::speakCueText): Speak a cue. (WebCore::HTMLMediaElement::pauseSpeakingCueText): (WebCore::HTMLMediaElement::resumeSpeakingCueText): (WebCore::HTMLMediaElement::cancelSpeakingCueText): (WebCore::HTMLMediaElement::shouldSpeakCueTextForTime): (WebCore::HTMLMediaElement::executeCueEnterOrLeaveAction): Trigger cue speech if the track contains descriptions and we are entering a cue range, schedule an enter or exit event. (WebCore::HTMLMediaElement::seekWithTolerance): INFO_LOG -> ALWAYS_LOG (WebCore::HTMLMediaElement::seekTask): Cancel speaking if necessary. (WebCore::HTMLMediaElement::finishSeek): Update logging. If there isn't a pending seek, queue a task to update text track cues. (WebCore::HTMLMediaElement::configureTextTrackGroup): When processing descriptions and the user wants text descriptions, set `fallbackTrack` to the first track seen in case none of the tracks matches the audio track language. (WebCore::HTMLMediaElement::playPlayer): Call resumeSpeakingCueText. (WebCore::HTMLMediaElement::pausePlayer): Call pauseSpeakingCueText. (WebCore::HTMLMediaElement::effectiveVolume const): Use the speech volume multiplier when calculating the effective volume. (WebCore::m_categoryAtMostRecentPlayback): Deleted. * Source/WebCore/html/HTMLMediaElement.h: (WebCore::HTMLMediaElement::cueBeingSpoken const): * Source/WebCore/html/shadow/MediaControlTextTrackContainerElement.cpp: (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Skip spoken tracks. * Source/WebCore/html/track/InbandGenericTextTrack.cpp: Remove unneeded include. * Source/WebCore/html/track/TextTrack.cpp: (WebCore::TextTrack::trackIndex): Use textTrackList() instead of m_textTrackList. (WebCore::TextTrack::isRendered): Consider descriptions. (WebCore::TextTrack::isSpoken): (WebCore::TextTrack::trackIndexRelativeToRenderedTracks): Use textTrackList() instead of m_textTrackList. (WebCore::TextTrack::speechSynthesis): * Source/WebCore/html/track/TextTrack.h: * Source/WebCore/html/track/TextTrackCue.cpp: (WebCore::operator<<): All cues have a `text()` method, just use it. * Source/WebCore/html/track/TextTrackCue.h: (WebCore::TextTrackCue::text const): (WebCore::TextTrackCue::speak): * Source/WebCore/html/track/VTTCue.cpp: (WebCore::VTTCue::updateDisplayTree): `track()` can return null, check it. (WebCore::VTTCue::getDisplayTree): Ditto. (WebCore::VTTCue::toJSON const): Drive-by: address a Darin FIXME. (WebCore::VTTCue::speak): * Source/WebCore/html/track/VTTCue.h: (WebCore::VTTCue::speechUtterance const): (WebCore::VTTCue::text const): Deleted. * Source/WebCore/html/track/VTTCue.idl: * Source/WebCore/page/CaptionUserPreferences.cpp: (WebCore::CaptionUserPreferences::userPrefersTextDescriptions const): Check audioDescriptionsEnabled setting. (WebCore::CaptionUserPreferences::textTrackSelectionScore const): Consider description tracks if the user preference is set. Clean up logic. * Source/WebCore/page/CaptionUserPreferencesMediaAF.cpp: (WebCore::CaptionUserPreferencesMediaAF::userPrefersCaptions const): (WebCore::CaptionUserPreferencesMediaAF::userPrefersTextDescriptions const): check MediaAccessibility framework preference. * Source/WebCore/page/CaptionUserPreferencesMediaAF.h: * Source/WebCore/platform/cf/MediaAccessibilitySoftLink.cpp: * Source/WebCore/platform/cf/MediaAccessibilitySoftLink.h: * Source/WebCore/platform/cocoa/PlatformSpeechSynthesizerCocoa.mm: (-[WebSpeechSynthesisWrapper speakUtterance:]): If `utteranceVoice` is non-NULL and the URI is empty, it is invalid so check the language. * Source/WebCore/platform/graphics/InbandGenericCue.cpp: (WebCore::InbandGenericCue::toJSONString const): Log cue text like VTTCue now does. * Source/WebCore/platform/graphics/iso/ISOVTTCue.cpp: (WebCore::ISOWebVTTCue::toJSONString const): Ditto. * Source/WebCore/testing/Internals.cpp: (WebCore::Internals::speechSynthesisUtteranceForCue): (WebCore::Internals::mediaElementCurrentlySpokenCue): * Source/WebCore/testing/Internals.h: * Source/WebCore/testing/Internals.idl: * Source/WebKit/UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::speechSynthesisSpeak): Remove the `startTime` parameter name, it isn't used. Canonical link: https://commits.webkit.org/253931@main
2afe52d
to
969ac99
Compare
Committed 253931@main (969ac99): https://commits.webkit.org/253931@main Reviewed commits have been landed. Closing PR #3486 and removing active labels. |
969ac99
2afe52d
π macπ mac-debugπ wincairoπ§ͺ ios-wk2π§ͺ api-iosπ§ͺ api-macπ§ͺ mac-wk1π§ͺ mac-wk2π§ͺ mac-AS-debug-wk2π§ͺ mac-wk2-stress