Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bca97ec authored by Charles Chen's avatar Charles Chen
Browse files

Removing IPA - IPA is already handled by the phoneme tag.

parent b29f8283
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -33,8 +33,6 @@ interface ITts {

    void speak(in String text, in int queueMode, in String[] params);

    void speakIpa(in String ipaText, in int queueMode, in String[] params);

    boolean isSpeaking();

    void stop();
@@ -51,8 +49,6 @@ interface ITts {

    boolean synthesizeToFile(in String text, in String[] params, in String outputDirectory);

    boolean synthesizeIpaToFile(in String ipaText, in String[] params, in String outputDirectory);

    void playEarcon(in String earcon, in int queueMode, in String[] params);

    void addEarcon(in String earcon, in String packageName, in int resId);
+3 −117
Original line number Diff line number Diff line
@@ -48,11 +48,9 @@ public class TtsService extends Service implements OnCompletionListener {

    private static class SpeechItem {
        public static final int TEXT = 0;
        public static final int IPA = 1;
        public static final int EARCON = 2;
        public static final int SILENCE = 3;
        public static final int TEXT_TO_FILE = 5;
        public static final int IPA_TO_FILE = 6;
        public static final int EARCON = 1;
        public static final int SILENCE = 2;
        public static final int TEXT_TO_FILE = 3;
        public String mText = null;
        public ArrayList<String> mParams = null;
        public int mType = TEXT;
@@ -326,28 +324,6 @@ public class TtsService extends Service implements OnCompletionListener {
        }
    }

    /**
     * Speaks the given IPA text using the specified queueing mode and parameters.
     *
     * @param ipaText
     *            The IPA text that should be spoken
     * @param queueMode
     *            0 for no queue (interrupts all previous utterances), 1 for
     *            queued
     * @param params
     *            An ArrayList of parameters. This is not implemented for all
     *            engines.
     */
    private void speakIpa(String ipaText, int queueMode, ArrayList<String> params) {
        if (queueMode == 0) {
            stop();
        }
        mSpeechQueue.add(new SpeechItem(ipaText, params, SpeechItem.IPA));
        if (!mIsSpeaking) {
            processSpeechQueue();
        }
    }

    /**
     * Plays the earcon using the specified queueing mode and parameters.
     *
@@ -617,8 +593,6 @@ public class TtsService extends Service implements OnCompletionListener {
                } else if (currentSpeechItem.mType == SpeechItem.TEXT_TO_FILE) {
                    synthToFileInternalOnly(currentSpeechItem.mText,
                            currentSpeechItem.mParams, currentSpeechItem.mFilename);
                } else if (currentSpeechItem.mType == SpeechItem.IPA) {
                    // TODO Implement IPA support
                } else {
                    // This is either silence or an earcon that was missing
                    silence(currentSpeechItem.mDuration);
@@ -714,51 +688,6 @@ public class TtsService extends Service implements OnCompletionListener {
        return true;
    }

    /**
     * Synthesizes the given IPA text to a file using the specified parameters.
     *
     * @param ipaText
     *            The String of IPA text that should be synthesized
     * @param params
     *            An ArrayList of parameters. The first element of this array
     *            controls the type of voice to use.
     * @param filename
     *            The string that gives the full output filename; it should be
     *            something like "/sdcard/myappsounds/mysound.wav".
     * @return A boolean that indicates if the synthesis succeeded
     */
    private boolean synthesizeIpaToFile(String ipaText, ArrayList<String> params,
            String filename, boolean calledFromApi) {
        // Only stop everything if this is a call made by an outside app trying
        // to
        // use the API. Do NOT stop if this is a call from within the service as
        // clearing the speech queue here would be a mistake.
        if (calledFromApi) {
            stop();
        }
        Log.i("TTS", "Synthesizing IPA to " + filename);
        boolean synthAvailable = false;
        try {
            synthAvailable = synthesizerLock.tryLock();
            if (!synthAvailable) {
                return false;
            }
            // Don't allow a filename that is too long
            if (filename.length() > MAX_FILENAME_LENGTH) {
                return false;
            }
            // TODO: Add nativeSynth.synthesizeIpaToFile(text, filename);
        } finally {
            // This check is needed because finally will always run; even if the
            // method returns somewhere in the try block.
            if (synthAvailable) {
                synthesizerLock.unlock();
            }
        }
        Log.i("TTS", "Completed synthesis for " + filename);
        return true;
    }

    @Override
    public IBinder onBind(Intent intent) {
        if (ACTION.equals(intent.getAction())) {
@@ -804,27 +733,6 @@ public class TtsService extends Service implements OnCompletionListener {
            mSelf.speak(text, queueMode, speakingParams);
        }

        /**
         * Speaks the given IPA text using the specified queueing mode and
         * parameters.
         *
         * @param ipaText
         *            The IPA text that should be spoken
         * @param queueMode
         *            0 for no queue (interrupts all previous utterances), 1 for
         *            queued
         * @param params
         *            An ArrayList of parameters. The first element of this
         *            array controls the type of voice to use.
         */
        public void speakIpa(String ipaText, int queueMode, String[] params) {
            ArrayList<String> speakingParams = new ArrayList<String>();
            if (params != null) {
                speakingParams = new ArrayList<String>(Arrays.asList(params));
            }
            mSelf.speakIpa(ipaText, queueMode, speakingParams);
        }

        /**
         * Plays the earcon using the specified queueing mode and parameters.
         *
@@ -1014,28 +922,6 @@ public class TtsService extends Service implements OnCompletionListener {
            return mSelf.synthesizeToFile(text, speakingParams, filename);
        }

        /**
         * Synthesizes the given IPA text to a file using the specified
         * parameters.
         *
         * @param ipaText
         *            The String of IPA text that should be synthesized
         * @param params
         *            An ArrayList of parameters. The first element of this
         *            array controls the type of voice to use.
         * @param filename
         *            The string that gives the full output filename; it should
         *            be something like "/sdcard/myappsounds/mysound.wav".
         * @return A boolean that indicates if the synthesis succeeded
         */
        public boolean synthesizeIpaToFile(String ipaText, String[] params,
                String filename) {
            ArrayList<String> speakingParams = new ArrayList<String>();
            if (params != null) {
                speakingParams = new ArrayList<String>(Arrays.asList(params));
            }
            return mSelf.synthesizeIpaToFile(ipaText, speakingParams, filename, true);
        }
    };

}