Title: [139970] trunk
Revision
139970
Author
cfleiz...@apple.com
Date
2013-01-17 00:14:30 -0800 (Thu, 17 Jan 2013)

Log Message

WebSpeech: implement voices list
https://bugs.webkit.org/show_bug.cgi?id=107014

Reviewed by Adam Barth.

Source/WebCore: 

Add in the Mac side code to return a list of voices. 
Adds a layout test, which is skipped for now, until the feature is enabled.

Test: platform/mac/fast/speechsynthesis/speech-synthesis-voices.html

* Modules/speech/SpeechSynthesis.cpp:
(WebCore::SpeechSynthesis::SpeechSynthesis):
* Modules/speech/SpeechSynthesis.h:
(SpeechSynthesis):
* Modules/speech/mac/SpeechSynthesisMac.mm:
(WebCore::SpeechSynthesis::initializeVoiceList):

LayoutTests: 

* platform/mac/TestExpectations:
* platform/mac/fast/speechsynthesis: Added.
* platform/mac/fast/speechsynthesis/speech-synthesis-voices-expected.txt: Added.
* platform/mac/fast/speechsynthesis/speech-synthesis-voices.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139969 => 139970)


--- trunk/LayoutTests/ChangeLog	2013-01-17 07:35:54 UTC (rev 139969)
+++ trunk/LayoutTests/ChangeLog	2013-01-17 08:14:30 UTC (rev 139970)
@@ -1,3 +1,15 @@
+2013-01-17  Chris Fleizach  <cfleiz...@apple.com>
+
+        WebSpeech: implement voices list
+        https://bugs.webkit.org/show_bug.cgi?id=107014
+
+        Reviewed by Adam Barth.
+
+        * platform/mac/TestExpectations:
+        * platform/mac/fast/speechsynthesis: Added.
+        * platform/mac/fast/speechsynthesis/speech-synthesis-voices-expected.txt: Added.
+        * platform/mac/fast/speechsynthesis/speech-synthesis-voices.html: Added.
+
 2013-01-16  Hajime Morrita  <morr...@google.com>
 
         NoEventDispatchAssertion in ContainerNode::removeChildren is too strict

Modified: trunk/LayoutTests/platform/mac/TestExpectations (139969 => 139970)


--- trunk/LayoutTests/platform/mac/TestExpectations	2013-01-17 07:35:54 UTC (rev 139969)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2013-01-17 08:14:30 UTC (rev 139970)
@@ -188,6 +188,9 @@
 # Speech input is not yet enabled.
 fast/speech
 
+# Speech synthesis is not yet enabled.
+platform/mac/fast/speechsynthesis
+
 # Speech _javascript_ API is not yet enabled.
 fast/events/constructors/speech-recognition-event-constructor.html
 

Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices-expected.txt (0 => 139970)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices-expected.txt	2013-01-17 08:14:30 UTC (rev 139970)
@@ -0,0 +1,12 @@
+This tests that we can get synthesizer voices on the Mac
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS voiceCount > 0 is true
+PASS foundEnglishVoice is true
+PASS foundDefaultVoice is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices.html (0 => 139970)


--- trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/speechsynthesis/speech-synthesis-voices.html	2013-01-17 08:14:30 UTC (rev 139970)
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="console"></div>
+
+<script>
+
+    description("This tests that we can get synthesizer voices on the Mac");
+
+    var speech = window.speechSynthesis;
+    var list = speech.getVoices();
+
+    var foundDefaultVoice = false;
+    var foundEnglishVoice = false;
+    var voiceCount = list.length;
+
+    for (var k = 0; k < list.length; k++ ) {
+        var voice = list[k];
+        if (voice.lang == "en-US") {
+            foundEnglishVoice = true;
+        }
+        if (voice.default) {
+            foundDefaultVoice = true;
+        }
+    }
+
+    shouldBeTrue("voiceCount > 0");
+    shouldBeTrue("foundEnglishVoice");
+    shouldBeTrue("foundDefaultVoice");
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (139969 => 139970)


--- trunk/Source/WebCore/ChangeLog	2013-01-17 07:35:54 UTC (rev 139969)
+++ trunk/Source/WebCore/ChangeLog	2013-01-17 08:14:30 UTC (rev 139970)
@@ -1,3 +1,22 @@
+2013-01-17  Chris Fleizach  <cfleiz...@apple.com>
+
+        WebSpeech: implement voices list
+        https://bugs.webkit.org/show_bug.cgi?id=107014
+
+        Reviewed by Adam Barth.
+
+        Add in the Mac side code to return a list of voices. 
+        Adds a layout test, which is skipped for now, until the feature is enabled.
+
+        Test: platform/mac/fast/speechsynthesis/speech-synthesis-voices.html
+
+        * Modules/speech/SpeechSynthesis.cpp:
+        (WebCore::SpeechSynthesis::SpeechSynthesis):
+        * Modules/speech/SpeechSynthesis.h:
+        (SpeechSynthesis):
+        * Modules/speech/mac/SpeechSynthesisMac.mm:
+        (WebCore::SpeechSynthesis::initializeVoiceList):
+
 2013-01-16  Rik Cabanier  <caban...@adobe.com>
 
         Update GraphicsContext to support winding rule in clip operator for Core Graphics

Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp (139969 => 139970)


--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-01-17 07:35:54 UTC (rev 139969)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp	2013-01-17 08:14:30 UTC (rev 139970)
@@ -37,6 +37,7 @@
     
 SpeechSynthesis::SpeechSynthesis()
 {
+    initializeVoiceList();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h (139969 => 139970)


--- trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h	2013-01-17 07:35:54 UTC (rev 139969)
+++ trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h	2013-01-17 08:14:30 UTC (rev 139970)
@@ -57,6 +57,7 @@
 private:
     SpeechSynthesis();
     
+    void initializeVoiceList();
     Vector<RefPtr<SpeechSynthesisVoice> > m_voiceList;
 };
     

Modified: trunk/Source/WebCore/Modules/speech/mac/SpeechSynthesisMac.mm (139969 => 139970)


--- trunk/Source/WebCore/Modules/speech/mac/SpeechSynthesisMac.mm	2013-01-17 07:35:54 UTC (rev 139969)
+++ trunk/Source/WebCore/Modules/speech/mac/SpeechSynthesisMac.mm	2013-01-17 08:14:30 UTC (rev 139970)
@@ -28,10 +28,34 @@
 
 #if ENABLE(SPEECH_SYNTHESIS)
 
+#include "SpeechSynthesisVoice.h"
 #include "SpeechSynthesisUtterance.h"
+#include <AppKit/NSSpeechSynthesizer.h>
 
 namespace WebCore {
     
+void SpeechSynthesis::initializeVoiceList()
+{
+    NSString *defaultVoiceURI = [NSSpeechSynthesizer defaultVoice];
+    NSArray *availableVoices = [NSSpeechSynthesizer availableVoices];
+    NSUInteger count = [availableVoices count];
+    for (NSUInteger k = 0; k < count; k++) {
+        NSString *voiceName = [availableVoices objectAtIndex:k];
+        NSDictionary *attributes = [NSSpeechSynthesizer attributesForVoice:voiceName];
+        
+        NSString *voiceURI = [attributes objectForKey:NSVoiceIdentifier];
+        NSString *name = [attributes objectForKey:NSVoiceName];
+        NSString *language = [attributes objectForKey:NSVoiceLocaleIdentifier];
+
+        // Change to BCP-47 format as defined by spec.
+        language = [language stringByReplacingOccurrencesOfString:@"_" withString:@"-"];
+        
+        bool isDefault = [defaultVoiceURI isEqualToString:voiceURI];
+        
+        m_voiceList.append(SpeechSynthesisVoice::create(voiceURI, name, language, true, isDefault));
+    }
+}
+
 bool SpeechSynthesis::pending() const
 {
     return false;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to