Fairy new to programming, 2nd post here. I'm attempting to make a personal project that takes an article(like a reddit article) and saves it to an mp3 or wav file that can be burned to a CD and listened to.
I am using the java JSoup library to grab the paragraph elements from the article and save them to a .txt file, which is working. I am also using java swing with freetts(currently in a separate project) to convert text to speech, which is also working.
My best guess as to the next step is to get the freetts to save the text to an audio file. Im trying to use a method called dumpAudio that i found on the freetts site, and i cant get it to work. So my question is,what am i doing wrong?
Here is my attempt at this(i only included the freetts code for brevity):
public class MyRedditProject extends javax.swing.JFrame {
// code is from https://www.youtube.com/watch?v=swuYhvwHw9w
/**
* Creates new form RedditProject
*/
public MyRedditProject() {
initComponents();
}
#SuppressWarnings("unchecked")
private static final String VOICENAME = "kevin16";
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Voice voice;
VoiceManager vm = VoiceManager.getInstance();
voice = vm.getVoice(VOICENAME);
voice.allocate();
try
{
voice.speak(jTextArea1.getText());
//trying to use dumpAudio to save text to audio file. I found the
//dumpAudio method on the freetts site
vm.dumpAudio("C:\\Users\\david\\Documents\\Reddit_Project\\dumpAudio.wav");
}
catch(Exception e)
{
}
Related
basically I just want to know, if there are ways on how to export excel sheet file in Podio with the comments section included in a certain app using API.
There is no direct API call to export to excel along with comments. Export work on Items and Apps
There is a work around to do this.
1. Make a CommentAPI call as per code attached, you can get all the comments on Item, so that you can export them to your excel programmatically.
public class APICall implements Serializable {
public static void main(String as[]){
APICall apiObj = new APICall();
apiObj.apicall();
}
/**
*
*/
public void apicall()
{
try{
System.out.println("inside");
ResourceFactory resourceFactory = new ResourceFactory(new OAuthClientCredentials("<WS NAME>","<Your authkey>"),new OAuthUsernameCredentials("<username>", "<Password>"));
CommentAPI capi = new CommentAPI(resourceFactory);
Reference ref= new Reference(ReferenceType.ITEM,561530318);
List<Comment> cmts = capi.getComments(ref);
for(Comment e : cmts )
System.out.println(e.getValue());
The google Vision's Barcode detection API works fine and gets the result of the scanned barcode using Android. But I didn't find any way to get the frame from which the barcode is detected. Is there any way to get that exact frame?
You can use detect(Frame) instead of receiveFrame(Frame).
When using receiveFrame(), you can only receive the barcode results returned by a processor:
class BarcodeTrackerFactory implements MultiProcessor.Factory<Barcode> {
private GraphicOverlay mGraphicOverlay;
BarcodeTrackerFactory(GraphicOverlay graphicOverlay) {
mGraphicOverlay = graphicOverlay;
}
#Override
public Tracker<Barcode> create(Barcode barcode) {
BarcodeGraphic graphic = new BarcodeGraphic(mGraphicOverlay);
return new GraphicTracker<>(mGraphicOverlay, graphic);
}
}
Whereas detect() is a synchronized method. So you can save the results with the exact frame.
What i want to do in my project is to play audio songs which are inside my Box account for that i am using box api . As i know we can not provide direct audio streaming for audio files in Box api for that i am trying to implement progressive download and playing audio file from sd card . i know i can play song inside on complete method of download but this is taking more time to download and than playing file . for that what i did i wrote my code for playing audio inside on progress method of downloading file but this method is getting called so many times because of that same song is playing multiple time at a time.
So is there any way to write code for progressive audio playing in Box api .if yes where should i write that ?
* Download a file and put it into the SD card. In your app, you can put the file wherever you have access to.
*/
final Box box = Box.getInstance(Constants.API_KEY);
String PATH = Environment.getExternalStorageDirectory() + "/chaseyourmusic"+folderpath;
File file = new File(PATH);
file.mkdirs();
final java.io.File destinationFile = new java.io.File(PATH + "/"
+ URLEncoder.encode(items[position].name));
/* final java.io.File destinationFile = new java.io.File(Environment.getExternalStorageDirectory() + "/"
+ URLEncoder.encode(items[position].name));*/
final ProgressDialog downloadDialog = new ProgressDialog(Browse.this);
downloadDialog.setMessage("Downloading " + items[position].name);
downloadDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
downloadDialog.setMax((int) items[position].file.getSize());
downloadDialog.setCancelable(true);
downloadDialog.show();
Toast.makeText(getApplicationContext(), "Click BACK to cancel the download.", Toast.LENGTH_SHORT).show();
final Cancelable cancelable = box.download(authToken, items[position].id, destinationFile, null, new FileDownloadListener() {
#Override
public void onComplete(final String status) {
downloadDialog.dismiss();
if (status.equals(FileDownloadListener.STATUS_DOWNLOAD_OK)) {
//Able to play audio here from sd card but this is playing after completion of download only which is taking more time .
}
else if (status.equals(FileDownloadListener.STATUS_DOWNLOAD_CANCELLED)) {
Toast.makeText(getApplicationContext(), "Download canceled.", Toast.LENGTH_LONG).show();
}
}
#Override
public void onIOException(final IOException e) {
e.printStackTrace();
downloadDialog.dismiss();
Toast.makeText(getApplicationContext(), "Download failed " + e.getMessage(), Toast.LENGTH_LONG).show();
}
#Override
public void onProgress(final long bytesDownloaded) {
downloadDialog.setProgress((int) bytesDownloaded);
//Want to write code here but this method is getting called multiple times which is creating problem in playing audio files from sd card .
}
});
downloadDialog.setOnCancelListener(new OnCancelListener() {
#Override
public void onCancel(DialogInterface dialog) {
cancelable.cancel();
}
});
Thanks
Use something like these:
http://code.google.com/p/npr-android-app/source/browse/Npr/src/org/npr/android/news/StreamProxy.java?r=41487c03f461942a5747378d197320412fe99442
http://www.java2s.com/Code/Android/File/StreamProxy.htm
Basically for progressive streaming, you proceed with the download as usual (in background) and you run a stream proxy (like a server in background) and push the data to your media player (you can use external media player or write a simple one by yourself, it is only few lines of code with Android media framework)
I have use something very similar with success.
In fact I am using the answer from this post (with minor modification)
MediaPlayer stutters at start of mp3 playback
I need to extract audio from a live stream on red5 and stream it separately. On nginx with rtmp module I'd just retranslate this stream via ffmpeg without videodata, but I have no idea how to do anything like this (with or without ffmpeg) on Red5.
The first link on google gave me this:
just register IStreamListeners on your IClientStreams, and then separate AudioData from VideoData in the RTMPEvents
But this doesn't help much. To be honest, this doesn't help at all. What are these IStreamListeners and how do I register them on IClientStream?
And, what is more misterious, how do I separate AudioData from VideoData in some RTMPEvents?
This is how your extend RTMPClient and capture the Audio or Video events
private class TestClient extends RTMPClient {
private int audioCounter;
private int videoCounter;
public void connect() {
private IEventDispatcher streamEventDispatcher = new IEventDispatcher() {
public void dispatchEvent(IEvent event) {
System.out.println("ClientStream.dispachEvent()" + event.toString());
String evt = event.toString();
if (evt.indexOf("Audio") >= 0) {
audioCounter++;
} else if (evt.indexOf("Video") >= 0) {
videoCounter++;
}
}
};
}
}
This simply counts the a/v events, but it will get you part of the way there. I suggest looking though the unit tests in red5 and there you can learn a lot.
I'm trying to pause a recording on an incoming call and resume it later. i'm using the andriod mediarecorder and trying to record in MPEG4. I tried pause/resume with resetting/stopping a recording and starting it with the setOutputFile(fd), fd being the filedescriptor of the audio file that was stopped/paused and hoped it would append but i had no luck. Is there a way to achieve this or append two recordings or should i give up on mediarecorder.
code:
private MediaRecorder media_recorder;
private String file_path = null;
public void startRecording(path)
{
file_path = path
media_recorder= new MediaRecorder();
media_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
media_recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
media_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
media_recorder.setOputputFile(path);
media_recorder.prepare();
}
public void pauseRecording()
{
media_recorder.stop();
media_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
media_recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
media_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
FileOutputStream paused_file = new FileOutputStream(file_path);
media_recorder.setOutputFile(paused_file.getFD());
}
public void resumeRecording()
{
media_recorder.prepare();
media_recorder.start();
}
pauseRecording() stops the recording but resume fails with message start failed.
Simple answer for your question is NO YOU CAN'T
Once you are recording the only possible actions are stop and reset.
So try to save your Call to SDCard after you Stop , and then again start Fresh Record and Stop it. Finally Combine both Audio File into one Audio file.
Record the audio as .wav file and Combine using this format.