Computer Help forum

Question

C# and razer kraken headphones

by scratje / March 29, 2018 6:16 AM PDT

I am trying to make a chatbot on C#. For some reason my Razer kraken headphones cant pick up any voice commands. I know my headset is working because I use it to talk to my friends over discord or skype. I know the programe I wrote is working since it works with other microphones.

If anyone knows what I should do please help me

thanks in advance Happy

Answer This Ask For Clarification
Discussion is locked
You are posting a reply to: C# and razer kraken headphones
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: C# and razer kraken headphones
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.

All Answers

Collapse -
Answer
No pun intended.
by R. Proffitt Forum moderator / March 29, 2018 9:43 AM PDT

It sounds as if your app is not setting the audio source. Try setting that first using the Windows controls before your app as you work on adding source control to your app.

Collapse -
Help
by scratje / March 30, 2018 9:13 AM PDT
In reply to: No pun intended.

Could you maybe help with that? I am not an experienced C# user and I don't really know what this means.

Thanks in advance

Collapse -
Sorry no.
by R. Proffitt Forum moderator / March 30, 2018 9:22 AM PDT
In reply to: Help

To write apps you would know how to set the source in the windows mixer manually. Not to upset you but basics like that should be mastered before coding.

Collapse -
Answer
There are programmer forums.
by R. Proffitt Forum moderator / March 30, 2018 9:27 AM PDT

But all ask you to show your work to get it done as well as your code that failed.

This is a discussion forum so I'll share what I see a lot of today. It's not good. Many post to the coding forums with no code or blatant "give me the code" and get rebuffed immediately. Some refuse to do research. Again, no one helps those that don't help themselves.

In your case it looks like the audio source needs to be changed. Just like Audacity folk go on and on about it not recording and ignore priors about setting the audio source. I worry that many of today's PC owners are too dependent on support.

Collapse -
The code then
by scratje / March 31, 2018 1:46 AM PDT

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech.Synthesis;
using System.Speech.Recognition;
using System.Diagnostics;

namespace Voice_Bot_v2
{
public partial class Form1 : Form
{
String[] grammarFile = (File.ReadAllLines(@"C:\Voice Bot\grammar.txt"));
String[] responseFile = (File.ReadAllLines(@"C:\Voice Bot\response.txt"));

SpeechSynthesizer speechSynth = new SpeechSynthesizer();
Boolean wake = true;

Choices grammarList = new Choices();
SpeechRecognitionEngine speechRecognition = new SpeechRecognitionEngine();

public Form1()
{
grammarList.Add(grammarFile);
Grammar grammar = new Grammar(new GrammarBuilder(grammarList));

try
{
speechRecognition.RequestRecognizerUpdate();
speechRecognition.LoadGrammar(grammar);
speechRecognition.SpeechRecognized += rec_speechRecognized;
speechRecognition.SetInputToDefaultAudioDevice();
speechRecognition.RecognizeAsync(RecognizeMode.Multiple);
}
catch { return; }

speechSynth.SelectVoiceByHints(VoiceGender.Female);


InitializeComponent();
}

public void say(String text)
{
speechSynth.SpeakAsync(text);
}

private void rec_speechRecognized(object sender, SpeechRecognizedEventArgs e)
{
String result = e.Result.Text;
int resp = Array.IndexOf(grammarFile, result);

if (result.Contains("wake"))
{
wake = true;
say("activated");
}
if (result.Contains("sleep"))
{
wake = false;
say("deactivated");
}

if (result.Contains("hey"))
{
say("I am here");
wake = true;
System.Threading.Thread.Sleep(10000);
wake = false;
}



if (wake == true)
{



if (responseFile[resp].IndexOf('+') == 0)
{
List<string> responses = responseFile[resp].Replace('+', ' ').Split('/').Reverse().ToList();
Random r = new Random();
say(responses[r.Next(responses.Count)]);
}
else
{
if (responseFile[resp].IndexOf('*') == 0)
{
if (result.Contains("date"))
{
say(DateTime.Now.ToString(@"M/d/yyyy"));
}
if (result.Contains("google"))
{
Process.Start("http://google.com");
}
if (result.Contains("youtube"))
{
Process.Start("https://www.youtube.com");
}



if (result.Contains("open grammar"))
{
Process.Start(@"C:\Voice Bot\grammar.txt");
}
if (result.Contains("open responds"))
{
Process.Start(@"C:\Voice Bot\response.txt");
}



if (result.Contains("time"))
{
say(DateTime.Now.ToString(@"hh\:mm ss"));
}
}
else
{
say(responseFile[resp]);
}
}

}

}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}

Collapse -
Visual studio's
by scratje / March 31, 2018 1:48 AM PDT

So I am building this app in visual studio's. All the References are added. I set the audio and listening in the Try loop:
try
{
speechRecognition.RequestRecognizerUpdate();
speechRecognition.LoadGrammar(grammar);
speechRecognition.SpeechRecognized += rec_speechRecognized;
speechRecognition.SetInputToDefaultAudioDevice();
speechRecognition.RecognizeAsync(RecognizeMode.Multiple);
}
catch { return; }

Where I say to pet it into my Default Audio Device (which is set to my Razer Kraken). So basically I set my audio source right?

Collapse -
See what a mess this forum makes of that?
by R. Proffitt Forum moderator / March 31, 2018 9:06 AM PDT
In reply to: Visual studio's

You need to get on the programming forums which handle code snippets. Try DaniWeb, CodeProject and such since here your code is mangled by the forum and unreadable.

Also, I see no code in your code to switch to another audio input. This is why I feel you might be very new to Windows and/or coding. Why not set the audio input before you run your app?

Popular Forums
icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

Does BMW or Volvo do it best?

Pint-size luxury and funky style

Shopping for a new car this weekend? See how the BMW X2 stacks up against the Volvo XC40 in our side-by-side comparison.