[Tts][TCSACR-477] Add new API and error enum value (#3754)
authorSuyeon Hwang <35016426+stom-hwang@users.noreply.github.com>
Mon, 13 Dec 2021 11:12:37 +0000 (20:12 +0900)
committerGitHub <noreply@github.com>
Mon, 13 Dec 2021 11:12:37 +0000 (20:12 +0900)
* [Tts] Add missing Error enum value
* [Tts] Add new API for repeating last played text
* Fix the property name and Remove description about UTF-8
* Fix pre/post condition description to make simply understand

Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
src/Tizen.Uix.Tts/Interop/Interop.Tts.cs
src/Tizen.Uix.Tts/Tizen.Uix.Tts/ErrorOccurredEventArgs.cs
src/Tizen.Uix.Tts/Tizen.Uix.Tts/ExceptionFactory.cs
src/Tizen.Uix.Tts/Tizen.Uix.Tts/RepeatedText.cs [new file with mode: 0644]
src/Tizen.Uix.Tts/Tizen.Uix.Tts/TtsClient.cs

index 00407eb..5de83b5 100755 (executable)
@@ -40,9 +40,9 @@ internal static partial class Interop
             IoError = Tizen.Internals.Errors.ErrorCode.IoError,                     /* I/O error */
             InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,   /* Invalid parameter */
             OutOfNetwork = Tizen.Internals.Errors.ErrorCode.Networkdown,            /* Network is down */
-            TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,                   /* No answer from the STT service */
+            TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,                   /* No answer from the TTS service */
             PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,   /* Permission denied */
-            NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,           /* STT NOT supported */
+            NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,           /* TTS NOT supported */
             InvalidState = ErrorTts | 0x01,                                         /* Invalid state */
             InvalidVoice = ErrorTts | 0x02,                                         /* Invalid language */
             EngineNotFound = ErrorTts | 0x03,                                       /* No available engine */
@@ -137,6 +137,9 @@ internal static partial class Interop
         [DllImport(Libraries.Tts, EntryPoint = "tts_pause", CallingConvention = CallingConvention.Cdecl)]
         internal static extern TtsError TtsPause(IntPtr handle);
 
+        [DllImport(Libraries.Tts, EntryPoint = "tts_repeat", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern TtsError TtsRepeat(IntPtr handle, out string text_repeat, out int utt_id);
+
         [DllImport(Libraries.Tts, EntryPoint = "tts_set_state_changed_cb", CallingConvention = CallingConvention.Cdecl)]
         internal static extern TtsError TtsSetStateChangedCB(IntPtr handle, TtsStateChangedCB callback, IntPtr userData);
 
index 007995b..be00286 100755 (executable)
@@ -111,6 +111,24 @@ namespace Tizen.Uix.Tts
                         ErrorValue = Error.AudioPolicyBlocked;
                         break;
                     }
+
+                case Interop.Tts.TtsError.NotSupportedFeature:
+                    {
+                        ErrorValue = Error.NotSupportedFeature;
+                        break;
+                    }
+
+                case Interop.Tts.TtsError.ServiceReset:
+                    {
+                        ErrorValue = Error.ServiceReset;
+                        break;
+                    }
+
+                case Interop.Tts.TtsError.ScreenReaderOff:
+                    {
+                        ErrorValue = Error.ScreenReaderOff;
+                        break;
+                    }
             }
         }
 
index a471f7d..aebf860 100755 (executable)
@@ -112,6 +112,12 @@ namespace Tizen.Uix.Tts
                         break;
                     }
 
+                case TtsError.ScreenReaderOff:
+                    {
+                        exp = new InvalidOperationException("Screen reader off");
+                        break;
+                    }
+
                 default:
                     {
                         exp = new Exception("");
diff --git a/src/Tizen.Uix.Tts/Tizen.Uix.Tts/RepeatedText.cs b/src/Tizen.Uix.Tts/Tizen.Uix.Tts/RepeatedText.cs
new file mode 100644 (file)
index 0000000..537ac7d
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+namespace Tizen.Uix.Tts
+{
+    /// <summary>
+    /// This class holds information about repeated text.
+    /// </summary>
+    /// <since_tizen> 10 </since_tizen>
+    public class RepeatedText
+    {
+        internal RepeatedText(string text, int uttId)
+        {
+            this.Text = text;
+            this.UtteranceId = uttId;
+        }
+
+        /// <summary>
+        /// The last played text.
+        /// </summary>
+        /// <since_tizen> 10 </since_tizen>
+        public string Text
+        {
+            get;
+            internal set;
+        }
+
+        /// <summary>
+        /// The utterance ID.
+        /// </summary>
+        /// <since_tizen> 10 </since_tizen>
+        public int UtteranceId
+        {
+            get;
+            internal set;
+        }
+    }
+}
index 6d2716c..4ee3356 100644 (file)
@@ -111,7 +111,7 @@ namespace Tizen.Uix.Tts
         /// <since_tizen> 3 </since_tizen>
         InvalidParameter,
         /// <summary>
-        /// No answer from the STT service.
+        /// No answer from the TTS service.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         TimedOut,
@@ -126,7 +126,7 @@ namespace Tizen.Uix.Tts
         /// <since_tizen> 3 </since_tizen>
         PermissionDenied,
         /// <summary>
-        /// STT not supported.
+        /// TTS not supported.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         NotSupported,
@@ -154,7 +154,22 @@ namespace Tizen.Uix.Tts
         /// Audio policy blocked.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        AudioPolicyBlocked
+        AudioPolicyBlocked,
+        /// <summary>
+        /// Not supported feature of current engine.
+        /// </summary>
+        /// <since_tizen> 10 </since_tizen>
+        NotSupportedFeature,
+        /// <summary>
+        /// Service reset.
+        /// </summary>
+        /// <since_tizen> 10 </since_tizen>
+        ServiceReset,
+        /// <summary>
+        /// Screen reader off.
+        /// </summary>
+        /// <since_tizen> 10 </since_tizen>
+        ScreenReaderOff
     };
 
     /// <summary>
@@ -612,7 +627,7 @@ namespace Tizen.Uix.Tts
         /// The Default Voice SupportedVoice value, 0 if unable to get the value.
         /// </returns>
         /// <pre>
-        /// The State should be ready.
+        /// The Client must be in the <see cref="State.Ready"/> state.
         /// </pre>
         public uint MaxTextSize
         {
@@ -676,7 +691,7 @@ namespace Tizen.Uix.Tts
         /// <exception cref="OutOfMemoryException">This exception can be due to out Of memory.</exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <pre>
-        /// The State should be created.
+        /// The Client must be in the <see cref="State.Created"/> state.
         /// </pre>
         public Mode CurrentMode
         {
@@ -749,7 +764,7 @@ namespace Tizen.Uix.Tts
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <exception cref="ArgumentException">This exception can be due to improper value provided while setting the value.</exception>
         /// <pre>
-        /// The State should be created or ready.
+        /// The Client must be in the <see cref="State.Created"/> or <see cref="State.Ready"/> state.
         /// </pre>
         public void SetCredential(string credential)
         {
@@ -768,13 +783,17 @@ namespace Tizen.Uix.Tts
         /// <feature>
         /// http://tizen.org/feature/speech.synthesis
         /// </feature>
-        /// <exception cref="InvalidOperationException">This exception can be due to an invalid state.</exception>
+        /// <exception cref="InvalidOperationException">
+        /// This exception can be due to the following reasons while setting the value:
+        /// 1. Invalid state
+        /// 2. Screen reader off
+        /// </exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <pre>
-        /// The State must be Created.
+        /// The Client must be in the <see cref="State.Created"/> state.
         /// </pre>
         /// <post>
-        /// If this function is successful, the TTS state will be ready.
+        /// If this function is successful, the Client will be in the <see cref="State.Ready"/> state.
         /// If this function is unsuccessful, ErrorOccurred event will be invoked.
         /// </post>
         public void Prepare()
@@ -788,7 +807,7 @@ namespace Tizen.Uix.Tts
         }
 
         /// <summary>
-        /// Disconnects from the STT service.
+        /// Disconnects from the TTS service.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <feature>
@@ -797,10 +816,10 @@ namespace Tizen.Uix.Tts
         /// <exception cref="InvalidOperationException">This exception can be due to an invalid state.</exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <pre>
-        /// The state must be ready.
+        /// The Client must be in the <see cref="State.Ready"/> state.
         /// </pre>
         /// <post>
-        /// If this function is successful, the TTS state will be created.
+        /// If this function is successful, the Client will be in the <see cref="State.Created"/> state.
         /// </post>
         public void Unprepare()
         {
@@ -870,7 +889,7 @@ namespace Tizen.Uix.Tts
         /// </exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <pre>
-        /// The state must be ready.
+        /// The Client must be in the <see cref="State.Ready"/> state.
         /// </pre>
         public string GetPrivateData(string key)
         {
@@ -907,7 +926,7 @@ namespace Tizen.Uix.Tts
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <exception cref="ArgumentException">This exception can be due to improper value provided while setting the value.</exception>
         /// <pre>
-        /// The state must be ready.
+        /// The Client must be in the <see cref="State.Ready"/> state.
         /// </pre>
         public void SetPrivateData(string key, string data)
         {
@@ -936,7 +955,7 @@ namespace Tizen.Uix.Tts
         /// </exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <pre>
-        /// The state must be created.
+        /// The Client must be in the <see cref="State.Created"/> state.
         /// </pre>
         public SpeedRange GetSpeedRange()
         {
@@ -956,10 +975,10 @@ namespace Tizen.Uix.Tts
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <remarks>
-        /// Locale MUST be set for UTF-8 text validation check.
+        /// Locale MUST be set for text validation check.
         /// </remarks>
         /// <param name="text">
-        /// An input text based UTF-8.
+        /// An input text.
         /// </param>
         /// <param name="language">
         /// The language selected from the SupportedVoice.Language Property obtained from GetSupportedVoices()(e.g. 'NULL'(Automatic),'en_US').
@@ -981,12 +1000,13 @@ namespace Tizen.Uix.Tts
         /// 1. Invalid State
         /// 2. Operation Failure
         /// 3. Invalid Voice
+        /// 4. Screen reader off
         /// </exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
         /// <exception cref="ArgumentException">This exception can be due to improper value provided while setting the value.</exception>
         /// <pre>
-        /// The state must be ready or playing or paused.
+        /// The Client must be in the <see cref="State.Ready"/>, <see cref="State.Playing"/>, or <see cref="State.Paused"/> state.
         /// </pre>
         public int AddText(string text, string language, int voiceType, int speed)
         {
@@ -1013,14 +1033,15 @@ namespace Tizen.Uix.Tts
         /// 1. Invalid State
         /// 2. Operation Failure
         /// 3. Out of Network
+        /// 4. Screen reader off
         /// </exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <exception cref="UnauthorizedAccessException">This exception can be due to permission denied.</exception>
         /// <pre>
-        /// The state must be ready or paused.
+        /// The Client must be in the <see cref="State.Ready"/> or <see cref="State.Paused"/> state.
         /// </pre>
         /// <post>
-        /// If this function succeeds, the TTS state will be playing.
+        /// If this function succeeds, the Client will be in the <see cref="State.Playing"/> state.
         /// </post>
         public void Play()
         {
@@ -1043,13 +1064,14 @@ namespace Tizen.Uix.Tts
         /// This exception can be due to the following reasons:
         /// 1. Invalid Stat
         /// 2. Operation Failure
+        /// 3. Screen reader off
         /// </exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <pre>
-        /// The state must be ready or playing or paused.
+        /// The Client must be in the <see cref="State.Ready"/>, <see cref="State.Playing"/>, or <see cref="State.Paused"/> state.
         /// </pre>
         /// <post>
-        /// If this function succeeds, the TTS state will be ready.
+        /// If this function succeeds, the Client will be in the <see cref="State.Ready"/> state.
         /// This function will remove all text added via AddText() and synthesized sound data.
         /// </post>
         public void Stop()
@@ -1073,13 +1095,14 @@ namespace Tizen.Uix.Tts
         /// This exception can be due to the following reasons:
         /// 1. Invalid State
         /// 2. Operation Failure
+        /// 3. Screen reader off
         /// </exception>
         /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
         /// <pre>
-        /// The state must be playing.
+        /// The Client must be in the <see cref="State.Playing"/> state.
         /// </pre>
         /// <post>
-        /// If this function succeeds, the TTS state will be Paused.
+        /// If this function succeeds, the Client will be in the <see cref="State.Paused"/> state.
         /// </post>
         public void Pause()
         {
@@ -1092,6 +1115,41 @@ namespace Tizen.Uix.Tts
         }
 
         /// <summary>
+        /// Repeats the last played text.
+        /// </summary>
+        /// <since_tizen> 10 </since_tizen>
+        /// <returns>
+        /// The RepeatedText value that stores the text to repeat and utterance ID.
+        /// </returns>
+        /// <feature>
+        /// http://tizen.org/feature/speech.synthesis
+        /// </feature>
+        /// <exception cref="InvalidOperationException">
+        /// This exception can be due to the following reasons:
+        /// 1. Invalid State
+        /// 2. Operation Failure
+        /// 3. Screen reader off
+        /// </exception>
+        /// <exception cref="NotSupportedException">This exception can be due to TTS not supported.</exception>
+        /// <pre>
+        /// The Client must be in the <see cref="State.Ready"/> state.
+        /// </pre>
+        /// <post>
+        /// If this function succeeds, the Client will be in the <see cref="State.Playing"/> state.
+        /// </post>
+        public RepeatedText Repeat()
+        {
+            TtsError error = TtsRepeat(_handle, out string text, out int uttId);
+            if (error != TtsError.None)
+            {
+                Log.Error(LogTag, "Repeat Failed with error " + error);
+                throw ExceptionFactory.CreateException(error);
+            }
+
+            return new RepeatedText(text, uttId);
+        }
+
+        /// <summary>
         /// Method to release resources.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>