Android文字转语音在设备上不起作用

时间:2018-08-14 18:10:59

标签: java android android-studio text-to-speech

文本到语音应用程序可以在模拟器上正常运行,但是在我的两个三星设备上,尽管该语言已经下载并且昨天也可以运行,但今天仍然无法运行。与我的设备或代码有关吗?

这是我的logcat输出

08-14 20:43:31.358 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_4_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_4_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.418 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_5_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_5_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.468 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_6_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_6_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.508 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_7_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_7_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.558 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_8_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_8_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.618 26355-26355/com.example.semra.text_to_speech_app W/art: Failed execv(/system/bin/dex2oat --runtime-arg -classpath --runtime-arg  --debuggable --instruction-set=arm64 --instruction-set-features=smp,a53 --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant=generic --instruction-set-features=default --dex-file=/data/app/com.example.semra.text_to_speech_app-1/split_lib_slice_9_apk.apk --oat-file=/data/dalvik-cache/arm64/data@app@com.example.semra.text_to_speech_app-1@split_lib_slice_9_apk.apk@classes.dex) because non-0 exit status
08-14 20:43:31.628 26355-26355/com.example.semra.text_to_speech_app W/System: ClassLoader referenced unknown path: /data/app/com.example.semra.text_to_speech_app-1/lib/arm64
08-14 20:43:31.638 26355-26355/com.example.semra.text_to_speech_app D/ContextRelationManager: ContextRelationManager() : FEATURE_ENABLED=true
08-14 20:43:31.638 26355-26355/com.example.semra.text_to_speech_app I/InstantRun: starting instant run server: is main process
08-14 20:43:31.738 26355-26355/com.example.semra.text_to_speech_app W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
08-14 20:43:31.878 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
08-14 20:43:31.878 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
08-14 20:43:31.918 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
    setTypeface with style : 0
08-14 20:43:31.938 26355-26355/com.example.semra.text_to_speech_app D/TextView: setTypeface with style : 0
08-14 20:43:31.998 26355-26355/com.example.semra.text_to_speech_app W/ResourcesManager: Resource getTopLevelResources for package com.samsung.SMToverlayDirs =Null
    Resource getTopLevelResources for package com.google.android.ttsoverlayDirs =Null
08-14 20:43:32.008 26355-26355/com.example.semra.text_to_speech_app I/TextToSpeech: Sucessfully bound to com.samsung.SMT
08-14 20:43:32.028 26355-26355/com.example.semra.text_to_speech_app D/SecWifiDisplayUtil: Metadata value : SecSettings2
08-14 20:43:32.028 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{6eff61d I.E...... R.....ID 0,0-0,0}
08-14 20:43:32.038 26355-26549/com.example.semra.text_to_speech_app D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
08-14 20:43:32.058 26355-26355/com.example.semra.text_to_speech_app I/TextToSpeech: Connected to ComponentInfo{com.samsung.SMT/com.samsung.SMT.SamsungTTSService}
08-14 20:43:32.058 26355-26550/com.example.semra.text_to_speech_app I/TextToSpeech: Set up connection to ComponentInfo{com.samsung.SMT/com.samsung.SMT.SamsungTTSService}
08-14 20:43:32.138 26355-26549/com.example.semra.text_to_speech_app I/Adreno: QUALCOMM build                   : f696b84, I59a6815413
    Build Date                       : 09/29/16
    OpenGL ES Shader Compiler Version: XE031.07.00.00
    Local Branch                     : 
    Remote Branch                    : quic/LA.BR.1.3.5_rb1.4
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
08-14 20:43:32.148 26355-26549/com.example.semra.text_to_speech_app I/OpenGLRenderer: Initialized EGL, version 1.4
08-14 20:43:32.188 26355-26355/com.example.semra.text_to_speech_app W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
08-14 20:43:32.198 26355-26549/com.example.semra.text_to_speech_app D/libGLESv1: DTS_GLAPI : DTS is not allowed for Package : com.example.semra.text_to_speech_app
08-14 20:43:32.208 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:32.218 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
    HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:32.228 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 63 - 0, 0) vi=Rect(0, 63 - 0, 0) or=1
08-14 20:43:32.248 26355-26355/com.example.semra.text_to_speech_app I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@a201d2 time:2839061
08-14 20:43:33.128 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 0
08-14 20:43:33.178 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 1
08-14 20:43:33.368 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 63 - 0, 0) vi=Rect(0, 63 - 0, 897) or=1
08-14 20:43:33.938 26355-26355/com.example.semra.text_to_speech_app W/art: Failed to open zip archive '/system/framework/qcom.fmradio.jar': I/O Error
08-14 20:43:35.048 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 0
08-14 20:43:35.078 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: ViewPostImeInputStage processPointer 1
08-14 20:43:35.098 26355-26355/com.example.semra.text_to_speech_app E/Error: lang_missing_data
08-14 20:43:35.118 26355-26355/com.example.semra.text_to_speech_app D/SecWifiDisplayUtil: Metadata value : SecSettings2
08-14 20:43:35.118 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: #1 mView = android.widget.LinearLayout{bd95b08 V.E...... ......I. 0,0-0,0 #10203a4 android:id/toast_layout_root}
08-14 20:43:35.128 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:35.188 26355-26549/com.example.semra.text_to_speech_app E/libGLESv2: HWUI Protection: wrong call from hwui context F: ES3-glCreateProgramSEC
08-14 20:43:35.198 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
08-14 20:43:35.268 26355-26549/com.example.semra.text_to_speech_app D/OpenGLRenderer: endAllStagingAnimators on 0x7fa6613400 (RippleDrawable) with handle 0x7fac7159e0
08-14 20:43:35.528 26355-26355/com.example.semra.text_to_speech_app V/ActivityThread: updateVisibility : ActivityRecord{57862a1 token=android.os.BinderProxy@a201d2 {com.example.semra.text_to_speech_app/com.example.semra.text_to_speech_app.MainActivity}} show : false
08-14 20:43:38.598 26355-26355/com.example.semra.text_to_speech_app D/ViewRootImpl: #3 mView = null

这是我的代码

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
TextToSpeech t_speech;
int result;
EditText edit_text;
String text;
Button b_sp,b_st;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.init();
}
public void init(){
    edit_text=(EditText)this.findViewById(R.id.editText);
    b_sp=(Button)this.findViewById(R.id.speak);
    b_st=(Button)this.findViewById(R.id.stop);
    b_sp.setOnClickListener(this);
    b_st.setOnClickListener(this);
    t_speech=new TextToSpeech(this, new TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {
            if(status==TextToSpeech.SUCCESS){
                result=t_speech.setLanguage(new Locale("tr", "TR"));
            }
            else{
                Toast.makeText(getApplicationContext(),"Text To Speech is not supported on your device",Toast.LENGTH_LONG).show();
            }
        }
    });
}
@Override
public void onClick(View v) {
    if(v.getId()==R.id.speak){
        if(result==TextToSpeech.LANG_MISSING_DATA){
            Toast.makeText(getApplicationContext(),"Text To Speech is not supported on your device",Toast.LENGTH_LONG).show();
        }
        else if( result==TextToSpeech.LANG_NOT_SUPPORTED){
            Toast.makeText(getApplicationContext(),"Text To Speech is not supported on your device",Toast.LENGTH_LONG).show();
            Log.e("Error","lang_missing_data");
            Intent installIntent = new Intent();
            installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(installIntent);
        }
        else {
            text = edit_text.getText().toString();
            t_speech.speak(text, TextToSpeech.QUEUE_FLUSH, null);
        }
    }
    else if(v.getId()==R.id.stop){
        if(t_speech!=null){
            t_speech.stop();

        }
    }
}
@Override
public void onDestroy() {
    super.onDestroy();
    if(t_speech!=null){
        t_speech.stop();
        t_speech.shutdown();
    }
}

}

有人知道什么地方可能出错或如何调试?

亲切的问候

1 个答案:

答案 0 :(得分:0)

它既可以是设备,也可以是代码。

我看到的一件主要事情是,您向后写了“ if(LANG_MISSING_DATA)”和“ if(LANG_NOT_SUPPORTED)”(交换)。

尽管任何设备都可以使用任何引擎,但三星设备经常使用三星语音引擎,而仿真器通常使用Google或PICO(PICO很老,并且不支持很多语言)。

调试建议:

1)不要在所有日志中使用完全相同的短语。如果执行此操作,则很难分辨是什么导致了错误。改为这样做:

if(status==TextToSpeech.SUCCESS){
                    result=t_speech.setLanguage(new Locale("tr", "TR"));
                }
                else{
                    Toast.makeText(getApplicationContext(),"initialization of tts failed",Toast.LENGTH_LONG).show();
                }

...

f(result==TextToSpeech.LANG_NOT_SUPPORTED){
                Toast.makeText(getApplicationContext(),"tts does not support the Locale/language specified",Toast.LENGTH_LONG).show();
            }

...

if( result==TextToSpeech.LANG_MISSING_DATA){
                Toast.makeText(getApplicationContext(),"tts is missing the data required for the locale/language specified",Toast.LENGTH_LONG).show();

另外要注意的一点是,如果您处于离线状态,则Google语音引擎可以对result = t_speech.setLanguage做出误报,然后在您实际请求语音时保持沉默。