/Tests/FliteEngineTestViewController.m

http://espeak-engine.googlecode.com/ · Objective C · 109 lines · 36 code · 17 blank · 56 comment · 4 complexity · 71f4bb5d42907d9151f26ea0123e72fa MD5 · raw file

  1. //
  2. // FliteEngineTestViewController.m
  3. // FliteEngineTest
  4. //
  5. // Created by Ing. Jozef Bozek on 30.3.2010.
  6. // Copyright Š 2010 bring-it-together s.r.o.. All Rights Reserved.
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions are met:
  10. //
  11. // 1. Redistributions of source code must retain the above copyright notice, this
  12. // list of conditions and the following disclaimer.
  13. //
  14. // 2. Redistributions in binary form must reproduce the above copyright notice,
  15. // this list of conditions and the following disclaimer in the documentation
  16. // and/or other materials provided with the distribution.
  17. //
  18. // 3. Neither the name of the author nor the names of its contributors may be used
  19. // to endorse or promote products derived from this software without specific
  20. // prior written permission.
  21. //
  22. // THIS SOFTWARE IS PROVIDED BY BRING-IT-TOGETHER S.R.O. "AS IS"
  23. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  26. // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. #import "FliteEngineTestViewController.h"
  33. #import "ESpeakEngine.h"
  34. @implementation FliteEngineTestViewController
  35. @synthesize textView;
  36. /*
  37. // The designated initializer. Override to perform setup that is required before the view is loaded.
  38. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  39. if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  40. // Custom initialization
  41. }
  42. return self;
  43. }
  44. */
  45. /*
  46. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  47. - (void)loadView {
  48. }
  49. */
  50. - (void)viewDidLoad {
  51. [super viewDidLoad];
  52. engine = [[ESpeakEngine alloc] init];
  53. engine.volume = 1;
  54. NSArray * languages = [engine supportedLanguages];
  55. for (NSString *lang in languages) {
  56. NSLog(@"%@", lang);
  57. }
  58. [engine setLanguage:@"en"];
  59. }
  60. /*
  61. // Override to allow orientations other than the default portrait orientation.
  62. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  63. // Return YES for supported orientations
  64. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  65. }
  66. */
  67. - (IBAction)speech {
  68. NSString * text = self.textView.text;
  69. [engine speak:text];
  70. }
  71. - (IBAction)changeGender:(UISegmentedControl*)control {
  72. if (control.selectedSegmentIndex == 0) {
  73. [engine setGender:kESpeakEngineGenerMale];
  74. } else {
  75. [engine setGender:kESpeakEngineGenerFemale];
  76. }
  77. }
  78. - (void)didReceiveMemoryWarning {
  79. // Releases the view if it doesn't have a superview.
  80. [super didReceiveMemoryWarning];
  81. // Release any cached data, images, etc that aren't in use.
  82. }
  83. - (void)viewDidUnload {
  84. // Release any retained subviews of the main view.
  85. // e.g. self.myOutlet = nil;
  86. }
  87. - (void)dealloc {
  88. [engine release];
  89. [textView release];
  90. [super dealloc];
  91. }
  92. @end