-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1127ce3
commit 8c46e67
Showing
16 changed files
with
196 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
using System.Collections.Generic; | ||
using MonkeyApp.Interfaces; | ||
using Xamarin.Forms; | ||
using Android.Speech.Tts; | ||
using MonkeyApp.Droid; | ||
|
||
[assembly:Dependency(typeof(TextToSpeech_Droid))] | ||
namespace MonkeyApp.Droid | ||
{ | ||
public class TextToSpeech_Droid : Java.Lang.Object, ITextToSpeech, TextToSpeech.IOnInitListener | ||
{ | ||
TextToSpeech speaker; | ||
string toSpeak; | ||
|
||
public TextToSpeech_Droid() { } | ||
|
||
public void Speak(string text) | ||
{ | ||
var ctx = Forms.Context; // useful for many Android SDK features | ||
toSpeak = text; | ||
if (speaker == null) | ||
{ | ||
speaker = new TextToSpeech(ctx, this); | ||
} | ||
else | ||
{ | ||
var p = new Dictionary<string, string>(); | ||
speaker.Speak(toSpeak, QueueMode.Flush, p); | ||
} | ||
} | ||
|
||
#region IOnInitListener implementation | ||
public void OnInit(OperationResult status) | ||
{ | ||
if (status.Equals(OperationResult.Success)) | ||
{ | ||
var p = new Dictionary<string, string>(); | ||
speaker.Speak(toSpeak, QueueMode.Flush, p); | ||
} | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using MonkeyApp.Interfaces; | ||
using System; | ||
using Windows.Phone.Speech.Synthesis; | ||
|
||
namespace MonkeyApp.WinPhone | ||
{ | ||
public class TextToSpeech_WinPhone : ITextToSpeech | ||
{ | ||
public TextToSpeech_WinPhone() { } | ||
|
||
public async void Speak(string text) | ||
{ | ||
var synth = new SpeechSynthesizer(); | ||
await synth.SpeakTextAsync(text); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using AVFoundation; | ||
using MonkeyApp.Interfaces; | ||
using MonkeyApp.iOS; | ||
using Xamarin.Forms; | ||
|
||
[assembly:Dependency(typeof(TextToSpeech))] | ||
namespace MonkeyApp.iOS | ||
{ | ||
public class TextToSpeech : ITextToSpeech | ||
{ | ||
public TextToSpeech() { } | ||
|
||
public void Speak(string text) | ||
{ | ||
var speechSynthesizer = new AVSpeechSynthesizer(); | ||
|
||
var speechUtterance = new AVSpeechUtterance(text) | ||
{ | ||
Rate = AVSpeechUtterance.MaximumSpeechRate / 4, | ||
Voice = AVSpeechSynthesisVoice.FromLanguage("en-US"), | ||
Volume = 0.5f, | ||
PitchMultiplier = 1.0f | ||
}; | ||
|
||
speechSynthesizer.SpeakUtterance(speechUtterance); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace MonkeyApp.Interfaces | ||
{ | ||
public interface ITextToSpeech | ||
{ | ||
void Speak(string text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters