opt
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -2,10 +2,12 @@ package com.mogo.utils.tts;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Bundle;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.UtteranceProgressListener;
|
||||
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@@ -16,11 +18,12 @@ import java.util.Locale;
|
||||
*/
|
||||
public class AndroidTTSPlayer extends UtteranceProgressListener implements TTSPlayer, TextToSpeech.OnInitListener {
|
||||
|
||||
private static final String TAG = "AndroidTTSPlayer";
|
||||
|
||||
private TextToSpeech mTtsEngine;
|
||||
private Context mContext;
|
||||
private boolean mIsSuccess = false;
|
||||
private Bundle mParams;
|
||||
private HashMap< String, String > mParams;
|
||||
|
||||
/**
|
||||
* {@link TextToSpeech.Engine#KEY_PARAM_STREAM},
|
||||
@@ -32,9 +35,10 @@ public class AndroidTTSPlayer extends UtteranceProgressListener implements TTSPl
|
||||
public AndroidTTSPlayer( Context context ) {
|
||||
mContext = context.getApplicationContext();
|
||||
mTtsEngine = new TextToSpeech( mContext, this );
|
||||
mParams = new Bundle();
|
||||
mParams.putInt( TextToSpeech.Engine.KEY_PARAM_STREAM, AudioManager.STREAM_ALARM );
|
||||
mParams.putInt( TextToSpeech.Engine.KEY_PARAM_STREAM, AudioManager.STREAM_ALARM );
|
||||
mParams = new HashMap<>();
|
||||
mParams.put( TextToSpeech.Engine.KEY_PARAM_STREAM, AudioManager.STREAM_ALARM + "" );
|
||||
mParams.put( TextToSpeech.Engine.KEY_PARAM_VOLUME, "1" );
|
||||
mParams.put( TextToSpeech.Engine.KEY_PARAM_PAN, "0" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +50,12 @@ public class AndroidTTSPlayer extends UtteranceProgressListener implements TTSPl
|
||||
|
||||
@Override
|
||||
public void speakTTS( String text ) {
|
||||
// mTtsEngine.speak()
|
||||
if ( !mIsSuccess ) {
|
||||
Logger.d( TAG, "do not support tts play." );
|
||||
return;
|
||||
}
|
||||
mParams.put( TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, text );
|
||||
mTtsEngine.speak( text, TextToSpeech.QUEUE_FLUSH, mParams );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.utils.tts;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-14
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class TTSPlayerFactory {
|
||||
|
||||
public static TTSPlayer getPlayer( Context context ) {
|
||||
return new AndroidTTSPlayer( context );
|
||||
}
|
||||
}
|
||||
@@ -74,5 +74,5 @@ MOGO_MODULE_PUSH_VERSION=1.0.1
|
||||
# 广告资源位
|
||||
MOGO_MODULE_AD_CARD_VERSION=1.0.1
|
||||
# 新鲜事
|
||||
MOGO_MODULE_FRESH_NEWS_VERSION=1.0.3
|
||||
MOGO_MODULE_FRESH_NEWS_VERSION=1.0.3.1
|
||||
|
||||
|
||||
@@ -19,5 +19,8 @@
|
||||
./gradlew :modules:mogo-module-main:clean :modules:mogo-module-main:uploadArchives
|
||||
./gradlew :modules:mogo-module-back:clean :modules:mogo-module-back:uploadArchives
|
||||
./gradlew :modules:mogo-module-guide:clean :modules:mogo-module-guide:uploadArchives
|
||||
./gradlew :modules:mogo-module-gps-simulator:clean :modules:mogo-module-gps-simulator:uploadArchives
|
||||
./gradlew :modules:mogo-module-gps-simulator-debug:clean :modules:mogo-module-gps-simulator-debug:uploadArchives
|
||||
./gradlew :modules:mogo-module-gps-simulator-noop:clean :modules:mogo-module-gps-simulator-noop:uploadArchives
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user