Automatic update from web-platform-tests Unprefix the Web Speech API This CL contains the following changes: - Unprefix the speech recognition part of the Web Speech API - Update the WebSpeechRecognitionContext feature status to experimental - Update WPTs with recent spec changes Intent to ship: https://groups.google.com/a/chromium.org/d/msgid/blink-dev/677c7f0e.2b0a0220.2e82a8.01f6.GAE%40google.com Fixed: 408029727 Change-Id: I261c5d1a855cb2028827a9e0a8282ef668506cf8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6422562 Feels: Evan Liu <evliu@google.com> Commit-Queue: Evan Liu <evliu@google.com> Reviewed-by: Rick Byers <rbyers@chromium.org> Cr-Commit-Position: refs/heads/main@{#1471977} -- wpt-commits: 540c28e4684d7c78b39805d6085a4c848c282c9f wpt-pr: 53052
67 lines
2.6 KiB
HTML
67 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<title>SpeechRecognition Concurrent MediaStreamTracks</title>
|
|
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
|
|
<script>
|
|
async function getAudioTrackFromFile(filePath) {
|
|
const audioContext = new AudioContext();
|
|
const response = await fetch(filePath);
|
|
const arrayBuffer = await response.arrayBuffer();
|
|
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);
|
|
const source = audioContext.createBufferSource();
|
|
source.buffer = audioBuffer;
|
|
|
|
const destination = audioContext.createMediaStreamDestination();
|
|
source.connect(destination);
|
|
source.start();
|
|
|
|
return destination.stream.getAudioTracks()[0];
|
|
}
|
|
|
|
promise_test(async (t) => {
|
|
const lang = "en-US";
|
|
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
|
|
// Create two SpeechRecognition instances
|
|
const speechRecognition1 = new SpeechRecognition();
|
|
speechRecognition1.processLocally = false;
|
|
speechRecognition1.lang = lang;
|
|
const speechRecognition2 = new SpeechRecognition();
|
|
speechRecognition2.processLocally = false;
|
|
speechRecognition2.lang = lang;
|
|
|
|
const audioTrack1 = await getAudioTrackFromFile("/media/speech.wav");
|
|
const audioTrack2 = await getAudioTrackFromFile("/media/speech.wav");
|
|
|
|
assert_true(audioTrack1 instanceof MediaStreamTrack, "Audio track 1 should be a valid MediaStreamTrack");
|
|
assert_true(audioTrack2 instanceof MediaStreamTrack, "Audio track 2 should be a valid MediaStreamTrack");
|
|
|
|
const recognitionPromise1 = new Promise((resolve) => {
|
|
speechRecognition1.onresult = (event) => {
|
|
const transcript = event.results[0][0].transcript;
|
|
resolve(transcript);
|
|
};
|
|
});
|
|
|
|
const recognitionPromise2 = new Promise((resolve) => {
|
|
speechRecognition2.onresult = (event) => {
|
|
const transcript = event.results[0][0].transcript;
|
|
resolve(transcript);
|
|
};
|
|
});
|
|
|
|
speechRecognition1.start(audioTrack1);
|
|
speechRecognition2.start(audioTrack2);
|
|
|
|
const transcript1 = await recognitionPromise1;
|
|
const transcript2 = await recognitionPromise2;
|
|
|
|
assert_equals(transcript1.toLowerCase(), "this is a sentence in a single segment", "Speech recognition 1 should correctly recognize speech");
|
|
assert_equals(transcript2.toLowerCase(), "this is a sentence in a single segment", "Speech recognition 2 should correctly recognize speech");
|
|
}, "Two SpeechRecognition instances should simultaneously recognize speech from audio files.");
|
|
</script>
|
|
</html>
|