Get time of speech in a video file (in code) - c#

I'm looking for a way (in java, c#..) to get the time when people speak in a video file (even in a movie).
I don't need to know the accurate words, just the time.
Output example:
00:03 - 01:03 (someone spoke for a minute),
03:00 - 06:12 (someone spoke again),
.
.
.
I have found Sphinx (written in java): http://cmusphinx.sourceforge.net/
but couldn't get it to recognize properly.
Any ideas?
Thanks.
EDIT:
This is what I've tried in sphinx (very basic):
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);
recognizer.startRecognition(somefile);
SpeechResult result;
while ((result = recognizer.getResult()) != null) {
System.out.println(result);
}
recognizer.stopRecognition();
There were only 3 results (there should be allot more).
EDIT2:
well, I tried this on a song in my computer:
https://www.assembla.com/code/sonido/subversion/nodes/12/sphinx4/src/sphinx4/edu/cmu/sphinx/tools/endpoint/Segmenter.java
This is the output:
DataStartSignal: creation time: 1399716763914
SpeechStartSignal
DoubleData: 44100Hz, first sample #: 8820, collect time: 200
DoubleData: 44100Hz, first sample #: 9261, collect time: 210
.....
DoubleData: 44100Hz, first sample #: 1745037, collect time: 39570
SpeechEndSignal
SpeechStartSignal
DoubleData: 44100Hz, first sample #: 1894536, collect time: 42960
......
Two Problems:
1. My goal is to be able to do it on movies. It works on audio files (.wav)
2. I'm not sure it works well. As you can see, the output says the speech started after 200 milliseconds, where actually it started after 3 seconds at least (the song is 'Bee Gees - How Deep Is Your Love').

I have found Sphinx (written in java): http://cmusphinx.sourceforge.net/ but couldn't get it to recognize properly.
Like you said, you do not need to recognize. To get only voice activity detection in Java with times see the segmenter class edu.cmu.sphinx.tools.endpoint.Segmenter

Related

Get game being streamed from user's activity on Discord

I'm writing a discord bot in .net, and I need to get the name of the game being streamed by a user.
In discord.py, this is possible with https://discordpy.readthedocs.io/en/rewrite/api.html?highlight=guild#discord.Streaming.details.
I'd like to do this in discord.net, but 'Activity', along with Activity cast to Game and StreamingGame, all return the name of the stream (when streaming), not the actual name of the game. (RichGame gives a null reference exception.)
The game being played is visible when viewing a streaming user on Discord, but as far as I could see, not in the API. So how does discord.py get it?
I checked other libraries and it seems discord.py is the only one supporting it.
I tried to read the source code, but I'm not at all well-versed enough in python to understand it.
Example below:
var user = _client.GetGuild(0).GetUser(0);
Console.WriteLine($"Activity - {user.Activity.Name}");
Console.WriteLine($"Type - {user.Activity.Type}");
var Game = user.Activity as Game;
Console.WriteLine($"Game - {Game.Name}");
var StreamingGame = user.Activity as StreamingGame;
Console.WriteLine($"StreamingGame - {StreamingGame.Name}");
Returns:
Type - Streaming
Game - !giveaway ... Fallout 2 war eh das beste...
StreamingGame - !giveaway ... Fallout 2 war eh das beste...
Querying the the twitch API works, but seems excessive, considering it's available in the discord.py library.
Any help would be appreciated, thank you.

Reading CI Frequency In C# With NI USB-6363

Working LabVIEW Code
Attached above is LabVIEW code that I have successfully used in the past to read frequency data from a device. I also usually use the Start Task VI between my property node and while loop.
I am trying to code this in C#. So far I have successfully been able to code analog Output's and analog Input's on my device, USB-6363, (so I know I am able to write and read data from the device successfully with C#).
I have also used multimeters (Grainger link at bottom of post) to read frequency data (Orange Hz mode that the device is set to in the picture).
However, my C# code seems to be having issues reading the frequency data. My C# code is attached. When I try running this program I get the following error. This is the same error that I get when using the example program called 'MeasDigFreqBuffCont_ExtClk_ArmStart.2013'. The code I show is just creating the task, I do call the code later in my program in a different section and that is how I am getting the error.
------------------------------------------------- Begin Error Code -------------------------------------------------
{Error=-200077 Message="Requested value is not a supported value for
this property. The property value may be invalid because it conflicts
with another property.\n\nProperty:
NationalInstruments.DAQmx.CIChannel.FrequencyDivisor\nRequested Value:
1\nPossible Values: 4 to 4294967295\nChannel Name: Digital
Frequency\n\nTask Name: _unnamedTask<0>\n\nStatus Code: -200077"}
------------------------------------------------- End Error Code --------------------------------------------------
In the example program it asks for a sample clock source (A PFI channel from the device). However in the LabVIEW code it does not ask for this. Is this example maybe more in detail than what I am trying to do?
Task frequencyInput = new Task();
frequencyInput.CIChannels.CreateFrequencyChannel(
"Dev1/ctr0",
"Digital Frequency",
200,
15000,
CIFrequencyStartingEdge.Rising,
CIFrequencyMeasurementMethod.DynamicAveraging,
0.001,
1,
CIFrequencyUnits.Hertz
);
frequencyInput.CIChannels["Digital Frequency"].FrequencyTerminal = "/Dev1/PFI0";
CounterSingleChannelReader counterFreq = new CounterSingleChannelReader(frequencyInput.Stream);
double counterFreqData = counterFreq.ReadSingleSampleDouble();
txtPFI0.Text = Convert.ToString(counterFreqData);
FLUKE (R) Fluke-115 Compact - Basic Features Digital Multimeter, 14° to 122°F Temp. Range
Formatting the error message:
Requested value is not a supported value for this property. The property value may be invalid because it conflicts with another property.
Property: NationalInstruments.DAQmx.CIChannel.FrequencyDivisor
Requested Value: 1
Possible Values: 4 to 4294967295
Task Name: _unnamedTask<0>
Status Code: -200077
According to the documentation, you are asking the device to use an invalid divisor. Change your 1 to a 4:
frequencyInput.CIChannels.CreateFrequencyChannel(
"Dev1/ctr0",
"Digital Frequency",
200,
15000,
CIFrequencyStartingEdge.Rising,
CIFrequencyMeasurementMethod.DynamicAveraging,
0.001,
/* here */ 4,
CIFrequencyUnits.Hertz
);
NI installs C# examples for DAQmx, and it includes one for measuring frequency:
C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DotNET4.0\Counter\Measure Digital Frequency\MeasDigFrequency_LowFreq1Ctr\CS

C# / nAudio - Sending a MIDI message to controller

I'm building my own custom midi mapping app, and so far so good. I've been using nAudio to recieve midi messages, and it's working like a charm.
But when wanting to send something back, I run into some trouble. To enable a light on my controller I gotta send a Note On message: 90 kk 01 for example, where kk equals the corresponding key. (see picture below)
However, it is not working. I'm not getting any error messages at all, but nothing is lighting up neither.
Example of what I'm sending:
midiOut = new MidiOut(MIDIInDevice);
midiOut.Send(MidiMessage.StartNote(56, 1, 0).RawData);
56 is the Note, 1 the volume, and 0 the channel.
Any idea what i'm doing wrong?
The page you posted says that the lights are controlled with Note On messages. I'm not familiar with the C# library, but I'm guessing StopNote sends a Note Off message. Try using the equivalent that sends a Note On message. (Perhaps StartNote?)
Choose right channel and try to send NoteOn event.
var noteOnEvent = new NoteOnEvent(0L, channel, note, 127, 200);
midi.Send(noteOnEvent.GetAsShortMessage());
midi.Send(noteOnEvent.OffEvent.GetAsShortMessage());

Checking a monitor's power status from a .net managed application

I need to check if the power of a display/monitor (is it ON or OFF ?).
I've tried with WMI, using the Win32_DesktopMonitor and check the "Availability", but the value returned is always 3 (powered on), even when the monitor is physically turned off.
Now, looking at a few threads here on StackOverflow, there's one direction I'd like to follow and it's the use of IMSVidDevice Interface, but I have no clue how to use it.
I have this link http://msdn.microsoft.com/en-us/library/windows/desktop/dd694527(v=vs.85).aspx to start.
It talks about using segment.h and segment.idl. There's also the mention of msvidctl.h.
I found an MS Video Control 1.0 Type Library which seems to be what I'm looking for (it has an IMSVidDevice interface defined) but I can't figure out how to use this library.
var devices = new MSVidCtlLib.MSVidOutputDevices();
Console.WriteLine("Found {0} devices", devices.Count);
foreach (MSVidCtlLib.IMSVidOutputDevice dev in devices)
{
Console.WriteLine("{0}: {1} - {2}", dev.Name, dev.Status, dev.Power);
}
But the devices.count is always zero. I have two monitors on my dev box.
What am I missing ?

C# Problems with Reading Standard Output

This ones got me stumped. So I'm making a program in C# to provide a GUI frontend for the Terraria Server. I have tried several methods but I always get the same problem.
First I start the process using System.Diagnostic.
Then I have tried several things, such as asynchronously reading the console output using BeginOutputReadLine or creating a Background worker to execute the following:
while (!terrariaProcess.StandardOutput.EndOfStream)
{
consoleOutput.Items.Add(terrariaProcess.StandardOutput.ReadLine());
}
But the output always comes out muddled.
Example
It should be: (How it looks if I use cmd to execute it)
Terraria Server v1.0.6.1
Choose World:
1 Test
n New World
d <number> Delete World
>>n
Choose size:
1 Small
2 Medium
3 Large
>>3
Enter World Name:
>>Hello World
However my program reads it as:
Terraria Server v1.0.6.1
1 Test
n New World
d <number> Delete World
>>n
Choose World: Terraria Server v1.0.6.1
1 Small
2 Medium
3 Large
>>3
Choose size: Terraria Server v1.0.6.1
>>Hello World
It does this no matter what method I use. Can someone help please? Am I being an idiot (again)?
EDIT:
On Jon's request I have made a small console application to try to do the same thing. I am having some trouble checking for console input from within a loop so I can only test up to the first prompt but it still seems broken.
My code:
Process terrariaProcess;
terrariaProcess = new Process();
terrariaProcess.StartInfo.FileName = "TerrariaServer.exe";
terrariaProcess.StartInfo.UseShellExecute = false;
terrariaProcess.StartInfo.RedirectStandardInput = true;
terrariaProcess.StartInfo.RedirectStandardOutput = true;
terrariaProcess.StartInfo.CreateNoWindow = true;
terrariaProcess.Start();
while (!terrariaProcess.StandardOutput.EndOfStream)
{
Console.WriteLine(terrariaProcess.StandardOutput.ReadLine());
}
The result output:
Terraria Server v1.0.6.1
1 Test
n New World
d <number> Delete World
Call the function Console.Out.Flush();

Categories

Resources