Ejemplo n.º 1
-1
 public void onClickSalvar(View view) {
   String s = tMsg.getText().toString();
   // Sintetiza a voz para arquivo
   File file = SDCardUtils.getPublicFile("arquivo-voz.wav", Environment.DIRECTORY_MUSIC);
   HashMap<String, String> params = new HashMap<String, String>();
   tts.synthesizeToFile(s, params, file.getAbsolutePath());
   toast("Voz salva em arquivo: " + file);
 }
Ejemplo n.º 2
-1
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {
      info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
      Log.e(TAG, "bad menuInfo", e);
      return false;
    }

    Uri chunkUri = ContentUris.withAppendedId(getIntent().getData(), info.id);

    switch (item.getItemId()) {
      case R.id.context_open:
        // Launch activity to view/edit the currently selected item
        startActivity(new Intent(Intent.ACTION_EDIT, chunkUri));
        return true;
      case R.id.context_delete:
        // Delete the chunk that the context menu is for
        getContentResolver().delete(chunkUri, null, null);
        return true;
      case R.id.context_play:
        // Launch activity to view/edit the currently selected item
        // startActivity(new Intent(Intent.ACTION_EDIT, chunkUri));
        Cursor cursor = (Cursor) getListAdapter().getItem(info.position);
        String chunk = cursor.getString(COLUMN_INDEX_CHUNKTEXT);
        if (chunk.length() > 351) {
          chunk = chunk.substring(0, 350);
        }
        mTts.speak(chunk, TextToSpeech.QUEUE_ADD, null);
        return true;
      case R.id.context_generateaudio:
        cursor = (Cursor) getListAdapter().getItem(info.position);
        String chunksFileName = cursor.getString(COLUMN_INDEX_TITLE).replaceAll(" ", "_");
        chunksFileName = chunksFileName + ".wav";
        chunk = cursor.getString(COLUMN_INDEX_CHUNKTEXT);
        if (chunk.length() > 3001) {
          chunk = chunk.substring(0, 3001);
        }

        // File path =
        // Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC+"/Life_of_Pi/");
        // path.mkdirs();
        /*
         * TODO: Using the "audiobook'sfilename" from that chunk,
         * 	look up the current title of the audiobook in the application
         *  use that current title to create a directory
         *  generate the output to that directory
         */

        Toast tellUser =
            Toast.makeText(
                this,
                "Generating audio: "
                    + cursor.getString(COLUMN_INDEX_FULLPATH_AND_FILENAME)
                    + " into folder: ",
                Toast.LENGTH_LONG);
        tellUser.show();

        mTts.synthesizeToFile(
            chunk,
            null,
            cursor.getString(
                COLUMN_INDEX_FULLPATH_AND_FILENAME)); // "/sdcard/Music/Life_of_Pi/Chapter_13.wav");
        // //tried changing to path variable but didnt
        // work.
        return true;
      default:
        return super.onContextItemSelected(item);
    }
  }