簡體   English   中英

Android文字轉語音在設備上不起作用

[英]Android-Text To Speech doesnot working on device

文字轉語音應用程序可以在模擬器上正常運行,但是在我的兩個三星設備上,盡管該語言已經下載並且昨天也可以運行,但今天仍然無法運行。 與我的設備或代碼有關嗎?

這是我的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();
    }
}

}

有人知道什么地方可能出錯或如何調試?

親切的問候

它既可以是設備,也可以是代碼。

我看到的一件主要事情是,您向后寫了“ 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,然后在您實際請求語音時保持沉默。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM