speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Allow switching of data mode in the Python API.


From: Christopher Brannon
Subject: [PATCH] Allow switching of data mode in the Python API.
Date: Thu, 24 Jun 2010 07:50:28 -0500

Currently, it is not possible to switch between text and SSML mode
in the Python API.  With this patch, it is now possible to do so.
The SSIPClient class now has a set_data_mode method.  It is used
as follows:

self.set_data_mode(DataMode.SSML) # Switch to SSML mode.
self.set_data_mode(DataMode.TEXT) # Switch to text mode.

This change was requested by Orca.
See https://bugs.gnome.org/show_bug.cgi?id=591709
---
 src/python/speechd/client.py |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/python/speechd/client.py b/src/python/speechd/client.py
index 7f267ae..881f13f 100644
--- a/src/python/speechd/client.py
+++ b/src/python/speechd/client.py
@@ -383,6 +383,16 @@ class PunctuationMode(object):
 
     """
 
+class DataMode(object):
+    """Constants for specifying the type of data contained within messages
+    to be spoken.
+
+    """
+    TEXT = 'off'
+    """Data is plain text."""
+    SSML = 'on'
+    """Data is SSML (Speech Synthesis Markup Language)."""
+
 class SSIPClient(object):
     """Basic Speech Dispatcher client interface.
 
@@ -702,6 +712,17 @@ class SSIPClient(object):
         """
         self._conn.send_command('SET', scope, 'OUTPUT_MODULE', name)
 
+    def set_data_mode(self, value, scope=Scope.SELF):
+        """Set the data mode for further speech commands.
+
+        Arguments:
+          value - one of the constants from the DataMode class.
+          scope -- see the documentation of this class.
+
+        """
+        assert value in (DataMode.TEXT, DataMode.SSML)
+        self._conn.send_command('SET', scope, 'SSML_MODE', value)
+
     def set_pitch(self, value, scope=Scope.SELF):
         """Set the pitch for further speech commands.
 
-- 
1.7.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]