PyDub opens window no matter what I have tried - pydub

I'm trying to make a music making program and used PyDub for playing sounds as I could change the pitch. However, it opens a window whenever playing a sound. No matter what I do, it will open a window.
I have tried using
startupinfo = subprocess.STARTUPINFO
startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess._subprocess.SW_HIDE
behind every
p = subprocess.Popen(conversion_command, stdin=devnull, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo)
but to no avail. I have also tried putting creationflags=0x08000000 in the
p = subprocess.Popen(conversion_command, stdin=devnull, stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=startupinfo)
which also does not work.
Edit: I found another post which set default creationflags to 0x08000000, which worked!

Related

Setting currentTime to anything sets time back to 0 in videojs

I'm doing something fairly simple with videojs. I simply want to set the time to an arbitrary point on the timeline by clicking on an externally build UI (not the default seek stuff, but a set of divs that are acting like a progress bar.)
All the documentation and every post seems to indicate that setting currentTime as in object.currentTime(time) works. But in my case it doesn't. Not in the console, not anywhere.
Here's my code:
function clearSetTimeBug(videoObj,timeToSetTo){
console.log('timeToSetTo:'+timeToSetTo);
console.log("-1."+videoObj.id()+" readyState(): "+videoObj.readyState());//returns 4 (loaded)
console.log("0."+videoObj.id()+" bufferedEnd(): "+videoObj.bufferedEnd());//returns about 2 seconds ahead of where the playhead is)
if(videoObj.bufferedEnd()>timeToSetTo){
console.log("1."+videoObj.id()+" currentTime(): "+videoObj.currentTime()); // returns a valid videojs object id and then shows the currentTime to be where the video's current timecode as a float.
videoObj.currentTime(timeToSetTo);//this should totally work!
console.log("2."+videoObj.id()+" currentTime(): "+videoObj.currentTime());// shows that the current time is 0!
}else{
//I added this to just go to as far as it's buffered, but this doesn't work either
console.log("3."+videoObj.id()+" currentTime(): "+videoObj.currentTime());
console.log("4. newTime: "+videoObj.bufferedEnd());
videoObj.currentTime(videoObj.bufferedEnd());
pageTime=videoObj.bufferedEnd();
console.log("5."+videoObj.id()+": "+videoObj.currentTime());// still shows that the current time is 0!
console.log("6. pageTime:"+pageTime);
}
}
The player is spun up like this:
function setUpPlayers(playerId,playlist,local_file,index){
let myAspectRatio=heightRatio+":1"
let videoTag="";
videoTag +="<video id='playerInstance"+index+"' class='video-js vjs-fluid' width='100%' height='100%'>\n";
videoTag +="\t<source src='"+playlist+"' type='video/mp4'>\n";
videoTag +="</video>\n"
$('#player'+index).html(videoTag);
window["vjPlayer"+index]=videojs("playerInstance"+index, {"autoplay": false, "preload": "auto" });
}
Play() and pause() and even currentTime() to get the current time works. But trying to set it just forces the player to go back to 0.
I'm working in a Mac in Chrome Version 86.0.4240.80 and Firefox Developer's Edition 71.0b1 (64-bit). These are all local files and I'm running it from http://localhost:8000/index.php.
In the video.js github channel, I figured out the answer to this question. I hadn't checked it on my server, so running the page locally screwed up the ability to click around and set currentTime. Quite strange, actually. I'm still not sure why it happens. You can see the comment here: https://github.com/videojs/video.js/issues/6900
Not the smartest move on my part, but hopefully this might help someone else in the future.

Automatic download of created file in Sencha Touch 2

My Sencha Touch 2 application has an 'Export' button, which creates an Excel file with the data of the selected offer.
After the user clicks the button, i want the (server side) export process to be started, and, once completed, the user to be prompted to select a filename and location, OR that the file is automatically downloaded. How do i do that? Does anyone have an example?
For Excel specifically I'm not 100% sure, but this might help you get started or if a CSV is acceptable...
I'm sure you could pass the file reference to a var instead of the string but I have yet to try it.
If you paste the js below into the console you can see how this works. Pretty basic. Maybe try the returned value from the server to see if that works then if it does you can build a function around it to happen when needed.
csvHeading = 'HA, HB, HC, HD \n';
csvData = 'r3a, r3b, r3c, r3d \n' +
'r2a, r2b, r2c, r2d';
CSVFile = csvHeading + csvData;
window.location = 'data:text/csv;charset=utf8,' + encodeURIComponent(CSVFile);

SpeechRecognitionEngine Spoken and Recorded do not match

I am using SpeechRecognitionEngine to recognize information being spoken by a user. The method will be running on the client's computer and it is working just fine and recognizing text almost like I want it to. So I'm happy.
However, I want to be able to do some processing of the wave file on my server. Right now I am testing on my local machine and when I use the SetInputToWaveFile method on the Recognizer, and pass the same audio clip back through (the one recorded by the engine originally) it does not give anything close to the original matches (or alternates).
For example:
User speaks and recognizer returns the phrase: "Hello how are you today" with 10 alternates.
Wave file is saved and then passed in through using SetInputToWaveFile (or SetInputToAudioStream). The recognizer will return a phrase (usually one word) that is nothing like the spoken text, example "Moon" along with ZERO alternates.
Often, when doing this, the recognizer will not raise the RecognizeCompleted event. It will however sometimes raise the SpeechHypothesized event, other times the AudioSignalProblem occured.
Shouldn't passing the audio clip that was captured from the recognizer results, back through the same recognizer, return the same matches?
Original:
Private _recognizer As New SpeechRecognitionEngine(New CultureInfo("en-US"))
_recognizer.UnloadAllGrammars()
_recognizer.LoadGrammar(New DictationGrammar())
_recognizer.SetInputToDefaultAudioDevice()
_recognizer.InitialSilenceTimeout = TimeSpan.FromSeconds(2)
_recognizer.MaxAlternates = 10
_recognizer.BabbleTimeout = TimeSpan.FromSeconds(1)
Dim result As RecognitionResult = _recognizer.Recognize()
Dim aud As RecognizedAudio = _result.Audio 'This is the audio that gets saved
aud.WriteToWaveStream("mypath")
(I've removed some of the logic code in between that pulls out the results, and does some processing)
Now trying to pull out from the Audio file:
_recognizer.SetInputToWaveFile("mypath")
'Doesn't work either
'_recognizer.SetInputToAudioStream(File.OpenRead("mypath"), New SpeechAudioFormatInfo(44100, AudioBitsPerSample.Sixteen, AudioChannel.Mono))
Dim result2 As RecognitionResult = _recognizer.Recognize()
The recognition/matches from result and result2 are not even close.
I manually set the speech audio format info, and now it works perfectly.
_recognizer.SetInputToAudioStream(File.OpenRead("mypath"), New SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, Nothing))

Setting a process' window to front. Why isn't this working when maximized?

I'm trying to get an app's window (let's say Firefox as an example) and bring it to the very front and focus it. It works fine when the program isn't maximized, allowing me to bring any of Firefox's windows to the front.
However when maximized, it just brings the whole group of windows to the front, regardless of whether or not it was the window I specifically chose. Here's what I'm using:
AXUIElementPerformAction (element, kAXRaiseAction);
ProcessSerialNumber psn = [self serialNumberOfPid: [appPid unsignedIntValue]];
SetFrontProcessWithOptions (&psn, kSetFrontProcessFrontWindowOnly);
Reading some other posts, I've tried this:
AXUIElementSetAttributeValue(element, kAXMainAttribute, kCFBooleanTrue);
AXUIElementSetAttributeValue(element, kAXFocusedAttribute, kCFBooleanTrue);
AXUIElementPerformAction (element, kAXRaiseAction);
ProcessSerialNumber psn = [self serialNumberOfPid: [appPid unsignedIntValue]];
SetFrontProcessWithOptions (&psn, kSetFrontProcessFrontWindowOnly);
What am I doing wrong? Why does it only happen when the windows are maximized? Is there a better way of doing this?
Try using the kAXFrontmostAttribute property:
AXUIElementSetAttributeValue(element, kAXFrontmostAttribute, kCFBooleanTrue);

Multiple Flv Component playback - through a for loop - rewind issues AS3 Flash CS4

I am building a "video wall" app in flash AS3. I am importing a movie clip with a flvPlayback component nested within, then Adding it to the display list 12 times in a for loop (which is based on the length of an xml file.) The xml file aslo points to the .source of the flv instance.
This method is working, for displaying video content on all screens BUT, it only loops the last flvPlayback component. The rest just go back to the first frame of the video.
var vidURL = vidXML.video_item[i].#url
SS.video.source = vidURL;
SS.video.autoRewind = true;
SS.video.autoPlay = true;
SS.video.addEventListener(VideoEvent.COMPLETE, Loop);
function Loop(event:VideoEvent):void
{
SS.video.play();
}
I have tried refering to the SS + [i] to call the event to rewind as soon as it happens (as the videos are different lengths) but have had no luck.
Any help would be appreciated.
Thanks
Jono
Don't worry chaps...
using the "event.target.play()" is triggered when each video finishes, and rewinds them all nicely.
Sorry.
Jono