I am new to windows phone app development. I am trying to build a simple speech recognition app using SpeechRecognizerUI class. But the problem is whenever i try to debug the app in my Lumia 520 device(working on 8.1 platform), it load the listener as usual and then debugger stopped automatically at the same time it load within a second, don't allow me sufficient time to speak even a single word. I am googling since 2 days but got nothing helpful. I have provided a single button on "MainPage.xml" of my app for which i have given the following code.
namespace Kundali
{
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private async void button_Click(object sender, RoutedEventArgs e)
{
![SpeechRecognizerUI][1] sprec = new SpeechRecognizerUI();
SpeechRecognitionUIResult result = await sprec.RecognizeWithUIAsync();
MessageBox.Show(string.Format("You said {0} ", result.RecognitionResult.Text));
}
}
When i tried to handle the exception in catch handler it shows the exception "The text associated with this error code could not be found" not even listening the single text. Some one please help me.
Actually i am working with Visual studio 2012 (Express for windows Phone 8) but my device is on 8.1. Is this the problem?? If yes then please provide the solution. How do i integrate the functionality of 8.1 in vs2012?
I can think of two possible causes:
Did you add the Speech capability and the Microphone capability in your manifest WMAppManifest.xml file?
Do you have speech support for your current language? (Try setting to en-US to test)
Did you try using TTS (Text to Speech) which is also compatible with Windows Phone 8.1?
Sample
Windows Phone 8.1 Text to Speech
Related
I am using the following code to check for network access in the start of my application
public async void CheckNetwork()
{
if (!NetworkAvailabilty.Instance.IsNetworkAvailable)
{
MessageDialog Message = new MessageDialog("Network access not available.", "Network Error");
Message.Commands.Add(new UICommand("Close"));
await Message.ShowAsync();
Application.Current.Exit();
}
}
This works as expected in Windows 10 desktop. But when I am running the app in my Phone, it fails to close the app. What could be the reason for this and how to force close my app ?
As a design principle, you are not supposed to manually close an app. Please refer to this link (adressed to WP8 developers, but is still valid).
But, if you are working on a test app for yourself, you can throw an exception which is the only way possible to close the app.
throw new Exception();
Please don't do that if you aim to publish your app on the market :
An unhandled exception in your app consumes resources unnecessarily both on the user’s phone and on the Windows Phone servers.
The phone generates and uploads crash dumps for unhandled exceptions to help you find and fix bugs in your code. Crashing your app to close it wastes the user’s battery power and network bandwidth.
try Application.Current.Terminate() instead of Exit()
Try execute ApplicationView.GetForCurrentView().TryConsolidateAsync().
I'm developing a game for Windows Phone 7.1 with XNA framework.
I know there is a way to prevent piracy for Windows Phone 7 (and 8.0, 8.1) - checking if the file "WMAppPRHeader.xml" exists in app directory.
I'm using this code:
try
{
Stream stream = TitleContainer.OpenStream("WPAppPRHeader.xml");
if (stream.CanRead)
{
stream.ReadByte();
stream.Close();
}
}
catch
{
//file read error, it means it was hacked
}
When use this code and upload my game to Windows phone marketplace as a "Beta" app, it works great. File "WPAppPRHeader.xml" is readable from my game and the test is passed.
But, when upload the same XAP in Windows Phone marketplace as a public app, this code fails and my game thinks that it was hacked (I'm checking this somewhere in the middle, so microsoft testers doesn't event recognise that something is wrong and my game succesfuly passes certification).
So, what am I doing wrong? Why the same code, the same XAP is working when it's Beta, and not working when it's Public?
I still don't know why TitleContainer.OpenStream is working in beta and not working in public market, but here is the code, that works in public market:
System.Xml.Linq.XDocument.Load("WPAppPRHeader.xml");
I am working on a project in which i have to integrate other apps/games with my platform. Through which i can run them. So their is one bad test solution is that i make them hardcodedly integrate them inside my framework as a part of framework. But that is crap.
So, my question is can i run other installed apps(these apps will be downloaded from store separately) through some code from my platform and I know data can be transfer from one app to other apps.
It should be like when i click on Play App Button then an installed app will get start and i transfer some settings to it and when user finish playing that app some data get transfer back to my platform and my platform resumes to corresponding state.
For opening other app form your app you have to know the uri for the app for example You want to open "another app"
string anotherappURI = "anotherapp_uri_value:///?anyVariable=value";
Uri uri = new Uri(anotherappURI);
await Launcher.LaunchUriAsync(uri);
And if you want to make a uri for your app so that it can be open from another app please follow the steps
Double click on package.appxmanifest file in the project
In the Declaration tab, select "Protocol" in the drop-down list and click on add
Enter "your_app_URI_displayname" as Display Name and "your_app_URI" as the Name
Save these changes
Now after activation (when your app is called and opened) how get the activation
Go to App.xaml.cs file
Override the OnActivated method
Insert this piece of code within :
Code:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as
ProtocolActivatedEventArgs;
// TODO: Handle URI activation
// The received URI is eventArgs.Uri.AbsoluteUri
}
}
NOTE: Please upvote and accept it as answer if helpful
I am running this sample of Hello world
My code is
private async void Button_Click(object sender, RoutedEventArgs e)
{
var synth = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();
Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Hello World");
var mediaElement = new MediaElement();
mediaElement.SetSource(stream,stream.ContentType);
mediaElement.Play();
}
when I debug it, I get an error:
An exception of type 'System.IO.FileNotFoundException' occurred in SunnahForKids.exe but was not handled in user code
Additional information: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
From the MSDN Reference
Requirements
Minimum supported client: Windows 8.1
Minimum supported server: Windows Server 2012 R2
Minimum supported phone: Windows Phone 8.1 [Windows Runtime apps only]
Namespace: Windows.Media.SpeechSynthesis, Windows::Media::SpeechSynthesis [C++]
That is probably because the voice is not installed on the device. To solve it just add a try catch block and it will only "speak" when the voice related to the region and language of your app IS installed. Otherwise it will run without speaking.
If you use Dependency walker to view the dependency of system.speech.dll, it would tell you that
"Error: Modules with different CPU types were found."
Set CPU to be x64 in Visual Studio might solve your problem. It works for me.
My requirement is text to speech in windows phone 7. So I search in google and I find out the link and I try to register in bing.com/developers page but its going some where
I have tried with this webpage link but its going to windows azure page.
http://www.bing.com/developers/appids.aspx
and I have followed this tutorial.
http://www.codeproject.com/Articles/259727/Text-to-speech-in-windows-phone7
Or else please suggest me any useful link for this problem.
Can anyone help me?
Just stumbled upon this question. Its quite old but I don't think you need Bing. The Bing speech controls are something I would use for speech to text, but you said you wanted text to speech. That can be accomplished quite easily on the Windows phone by using the SpeechSynthesizer. Please see this tutorial here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207057(v=vs.105).aspx
I just added simple text-to-speech capabilities to my Windows Phone 7 app (well, the beta version) using Text-To-Speech with Microsoft Translator Service.
You can download it from their site, NuGet, or from within Visual Studio (that's how I found it - Manage NuGet Packages - search for "Text-To-Speech").
Here's some C# code to get started...
// required for SpeechSynthesizer
using TranslatorService.Speech;
namespace AppName
{
public partial class MainPage : PhoneApplicationPage
{
private void TextToSpeech_Play(object sender, EventArgs e)
{
SpeechSynthesizer speech = new SpeechSynthesizer(CLIENT_ID, CLIENT_SECRET);
speech.SpeakAsync("This is a beautiful day!");
}
}
}
To use this library, you need to go to Azure DataMarket and register your application to obtain the Client ID and Client Secret that are necessary to use the service. You also need to go to https://datamarket.azure.com/dataset/1899a118-d202-492c-aa16-ba21c33c06cb and subscribe the Microsoft Translator Service. There are many options, based on the amount of characters per month. The service is free up to 2 million characters per month.