質問タイトル通りです。急いでLogを見ようと思っていますがまだ見れません。
x86(実機はx86)に対応していないのかもしれません。でも元のアプリは動いたので…
AquesTalk
Java
1 2package sample.aquest.solarand; 3 4import android.app.Activity; 5import android.os.Bundle; 6import android.media.MediaPlayer; 7import android.util.Log; 8import android.widget.TextView; 9import java.io.*; 10 11import aquestalk2.AquesTalk2; 12import android.widget.*; 13import android.view.View.*; 14import android.view.*; // AquesTalk2クラス 別途libAquesTalk2.soが必要 15 16 17public class HelloAquesTalk2 extends Activity { 18 /** Called when the activity is first created. */ 19 @Override 20 public void onCreate(Bundle savedInstanceState) { 21 super.onCreate(savedInstanceState); 22 Button b=(Button) findViewById(R.id.Click); 23 b.setOnClickListener(new OnClickListener(){ 24 25 @Override 26 public void onClick(View p1){ 27 String koe = ""; 28 29 int speed = 90; // 発話速度 50-300 default:100 30 int phontResID = R.raw.aq_robo; // 声種 31 try { 32 // リソースからPhontデータを読み込み (デフォルトのPhontを使用するときは不要) 33 InputStream in = getResources().openRawResource(phontResID); 34 int size = in.available(); // リソースのデータサイズ 35 byte[] phontDat = new byte[size]; 36 in.read(phontDat); 37 38 // 音声合成 39 AquesTalk2 aquestalk2 = new AquesTalk2(); 40 byte[] wav = aquestalk2.syntheWav(koe, speed, phontDat); 41 42 43 if(wav.length==1){//生成エラー時には,長さ1で、先頭にエラーコードが返される 44 Log.v("AQTKAPP", "AquesTalk2 Synthe ERROR:"+wav[0]); 45 } 46 else { 47 PlayWav(wav);//音声データを再生出力 48 } 49 }catch (IOException e) { 50 } 51 TextView textView = (TextView) findViewById(R.id.mainTextView); 52 textView.setText("音声記号列:"+koe 53 +" speed:"+speed 54 +" phont:"+getResources().getResourceEntryName(phontResID)); 55 setContentView(textView); 56 } 57 }); 58 } 59 60 private void PlayWav(byte[] wav) { 61 // 一旦ファイルに出力してから、MediaPlayerで再生 62 String tmpfilename = "tmp_hello.wav"; 63 String packagename = removeSuffix(this.getClass().getName()); 64 65 try { 66 FileOutputStream fileOutputStream = openFileOutput(tmpfilename, MODE_WORLD_READABLE);//MODE_PRIVATEはNG! 67 fileOutputStream.write(wav); 68 fileOutputStream.close(); 69 } catch (IOException e) { 70 Log.e("AQTKAPP", "ERR: FileOutputStream"); 71 } 72 try { 73 MediaPlayer mp = new MediaPlayer(); 74 // mp.reset(); // MediaPlayerインスタンスを複数回使うときは必要 75 mp.setDataSource("/data/data/"+packagename+"/files/"+tmpfilename); 76 mp.prepare(); //<<忘れると動かない (-38,0)のようなエラーがでる 77 mp.start(); 78 } catch (IOException e) { 79 } 80 81 } 82 83 public static String removeSuffix(String fileName) { 84 if (fileName == null) 85 return null; 86 int point = fileName.lastIndexOf("."); 87 if (point != -1) { 88 return fileName.substring(0, point); 89 } 90 return fileName; 91 } 92 /*byte[] wav = aquestalk2.syntheWav(koe, speed, null); //< デフォルトのPhontを使用する場合 93 byte[] wav = AquesTalk2.synthe(koe, speed, phontDat); //< 静的メソッドもOK*/ 94}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。