I am creating an application which converts text to speech using silverlight 4.0. Two options which I found can be used are:
Use TTS at client side, which requires the application to be run OOB. Also since it uses native windows components, can't be used in any other platforms (MAC).
Use TTS conversion at WCF end. This again requires the WCF service to be hosted on IIS with Local System account for application pool.
Are there any other options in which we dont have to provide the elevated permissions?
The Bing translator service has TTS for several languages. Maybe it is possible to just use the TTS part without the translation. This blog post explains how to call the service and perform TTS from Silverlight:
http://timheuer.com/blog/archive/2010/03/22/silverlight-translator-text-to-speech-api.aspx
Another good solution is using google TTS - http://translate.google.com/translate_tts
The code would be like this:
string url = string.Format("http://translate.google.com/translate_tts?tl=en&q={0}", textToSay);
WebClient client = new WebClient();
return client.DownloadData(url);
If using silverlight, the data which is fetched from the above code(in byte array), can be set as the source of media element with converting to memore stream as below:
_audioPlayer.SetSource(new MemoryStream(textToSpeech));
Where textToSpeech is the byte array as returned from google tts.
Related
Does anyone know a way to stream .mp4 video from a secure azure blob (via https) into a WPF application.
I'm generating the uri as follows ...
public Uri GetSecureUriForBlob(CloudBlobContainer container, string blobName)
{
var blockBlob = container.GetBlockBlobReference(blobName);
var beforeOffset = new DateTimeOffset(DateTime.UtcNow.AddMinutes(-5));
var afterOffset = new DateTimeOffset(DateTime.UtcNow.AddHours(1));
var builder = new UriBuilder(blockBlob.Uri)
{
Query = blockBlob.GetSharedAccessSignature(
new SharedAccessBlobPolicy
{
Permissions = SharedAccessBlobPermissions.Read,
SharedAccessStartTime = beforeOffset,
SharedAccessExpiryTime = afterOffset
}).TrimStart('?')
};
return builder.Uri;
}
I've checked that the service version is set to at least "2013-08-15" and that the blob item has the correct content type set.
I know the format of the uri is correct, because I can paste it in a browser, and also use it in a Windows 8 store application, and the video streams correctly.
However, when I assign the same uri as the source for a WPF MediaElement, I get a NullReferenceException deep in the inner workings of MediaPlayer.Open().
There seems to be a known issue with WPF MediaElement when playing from HTTPS endpoints. There are no issues when playing over plain HTTP (without "S").
This is not Microsoft Azure related, or Blob Related. This is pure WPF issue, that however seems that will not be fixed soon, if fixed at all.
For HTTPS Streams you can use either Silverlight or Windows 8 Modern applications - both support HTTPS streams without any issues.
You could probably find a 3rd party control for WPF that supports playing media over HTTPS.
UPDATE
Using the VideoLan.NET WPF Controls I was able to make HTTPS media playing. So far the only controls for WPF that successfully play HTTPS media. This requires a valid installation of VideoLAN VLC player for Windows. I used the portable one (ZIP package) and it works perfectly. Documentation for the VideoLan.NET is a bit messy, but the result is that you can safely play HTTPS streams/progressive downloads in WPF.
I havent looked at the samples yet for the SkyDrive.
I have done a application that saves some data in a local database on the phone.
What i want to do is to upload all these to a SkyDrive account as a textfile.
Is this possible?
Might want to start with a blog post I wrote - Adding SkyDrive support to your Windows Phone application. You will need to download the Live SDK (unless you want to use the REST API manually, which I can see no reason for at this point).
Uploading is fairly simple after that, given that you obtained the proper session init:
client = new LiveConnectClient(App.MicrosoftAccountSession);
client.UploadCompleted += MicrosoftAccountClient_UploadCompleted;
client.UploadProgressChanged += MicrosoftAccountClient_UploadProgressChanged;
client.UploadAsync("me/skydrive", Binder.Instance.CurrentlyUploading,
stream, OverwriteOption.Overwrite);
Where stream is a MemoryStream instance.
I'm trying to access a run-of-the-mill REST API through a silverlight application, but can't seem to get basic authentication to work (using silverlight 4.0).
I'm using a .NET WebClient, and setting the webclient.Credentials with a valid username/password (for the API).
I'm running into two main errors:
System.NotSupportedException: BrowserHttpWebRequest does not support custom credentials.
(this only occurs when I set the webclient.UseDefaulCredentials to false)
and
System.NotImplementedException: This property is not implemented by this class.
at System.Net.WebRequest.set_Credentials(ICredentials value)
(occurs when webclient.UseDefaultCredentials isn't set at all)
what am I missing here? Is basic auth still not supported in Silverlight 4.0?
There is an article about it here http://mark.mymonster.nl/2009/12/02/silverlight-4-credentials-weve-got-it/ and it seems the magic line is:
WebRequest.RegisterPrefix("http://", System.Net.Browser.WebRequestCreator.ClientHttp);
In my case it seems to send the credentials, but I still end up with a 401 error but I just grabbed one of my web servers to try and it may not be configured correctly, but this seems like it should work.
I would also suggest trying the open source library Hammock for REST It provides a very useful wrapper around a lot of modern web calls like REST and oAuth.
I have a custom proxy class for a single WCF web-service (takes a string in, sends a string back). The asynchronous web service call works great from my Windows Form app. However, when I call it from a test Silverlight app I get an error: Hresult 0x80000012. This error is for Extension Attributes on files I believe... Go figure.
Using Fiddler I can confirm that no traffic is making it to IIS which is hosting the service, so it isn't the usual cross-domain restriction issue. I've tried using both "localhost" (which works in the Windows Forms app) and a name defined in my hosts file just in case "localhost" was causing the problem.
I've tested it by making the async call from the UI thread and also from a thread-pool queue item with the same results.
The proxy code is basically just simplified down from what the MS proxy generator creates, setting up bindings and settings programatically instead of via config files, and I use basically the same source to compile normal .Net and Silverlight versions of the libraries involved. (Now, the MS proxy code it is based on is from a WCF web service, not from the RIA template code, so maybe there are differences there...)
Four days of fruitless search on this one. Any help or suggestions would be wildly appreciated!
Figured it out. I was using (stupidly) a backslash in part of the URL that I used to set up the service call. Most of the interior parts of the MS code handled that ok and transposed them to forward slashes -- on Windows Forms everything worked seamlessly in fact. However, the Silverlight libraries couldn't handle it and threw the very helpful "HResult 0x80000012" error.
Changing my backslashes to slashes seems to have fixed the problem!
I have one very weird question.
There are 2 Silverlight Client
1. Admin
2. User
Now, I want a scenario wherein the Admin Silverlight can initiate a function call on the User Silverlight.
Pretty much a newbie with SL so wonder if that would be possible.
I'd appreciate any help.
Thanks
I suppose the applications are not in the same browser / machine, and when you describe the usage pattern as admin and user, I take that there are probably more users than admins.
You might want to take a look at duplex bindings for WCF services - this is a web service binding that allows pushing notifications to clients from the server. When all clients establish such a channel, you can implement hub-and-spoke communication between clients.
This blog post gives a good receipt for getting started:
http://silverlightforbusiness.net/2009/06/23/pushing-data-from-the-server-to-silverlight-3-using-a-duplex-wcf-service/
If they are both in the same frame/browser, you could call JavaScript in the first using the HtmlPage API, which could interact with the second.
So:
Silverlight control -> injects JS into HtmlPage -> JS interacts with Silverlight control 2 (assuming this is possible, please correct me if wrong) -> Silverlight control responds.
If they are in separate windows or running "out of browser", I would expect it wouldn't work.
If the 2 instances are seperated (i.e., the admin is on one machine and the user is on another) there's no direct way to do it. However, you can rig it up with a publisher/subscriber style system.
Assumption: You have some sort of shared data store between the two, maybe a database or something.
Idea: You have the admin client write a request to this shared data store; an entry in a table, or a new file in a network share, or something. You have the user client app regularly scan this table/share for new entries, say every .5 seconds or so. When it sees the entry, it executes the requested operation, storing any return values back to the shared store. When the admin sees the return value, he knows the operation has been successfully executed.
There are a couple of options that I can think of.
You could implement some sort of remote procedure call via web services whereby one Silverlight app posts a request to call the method, and the other Silverlight regularly checks for method call requests.
If hosted on the same HTML page in a browser, you could use javascript to allow the two controls to interact.
However, direct communication between two Silverlight instances isn't supported, and while the suggestions may help to achieve something close to what you want, they don't provide a complete solution that will work in all scenarios.