eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VoiceVariantTest.java 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2013 Reece H. Dunn
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.reecedunn.espeak.test;
  17. import android.test.AndroidTestCase;
  18. import com.reecedunn.espeak.SpeechSynthesis;
  19. import com.reecedunn.espeak.VoiceVariant;
  20. import static org.hamcrest.MatcherAssert.assertThat;
  21. import static org.hamcrest.Matchers.*;
  22. public class VoiceVariantTest extends AndroidTestCase
  23. {
  24. public void testMaleVoiceVariant()
  25. {
  26. VoiceVariant variant = VoiceVariant.parseVoiceVariant("male");
  27. assertThat(variant.variant, is(nullValue()));
  28. assertThat(variant.gender, is(SpeechSynthesis.GENDER_MALE));
  29. assertThat(variant.age, is(SpeechSynthesis.AGE_ANY));
  30. assertThat(variant.toString(), is("male"));
  31. }
  32. public void testFemaleVoiceVariant()
  33. {
  34. VoiceVariant variant = VoiceVariant.parseVoiceVariant("female");
  35. assertThat(variant.variant, is(nullValue()));
  36. assertThat(variant.gender, is(SpeechSynthesis.GENDER_FEMALE));
  37. assertThat(variant.age, is(SpeechSynthesis.AGE_ANY));
  38. assertThat(variant.toString(), is("female"));
  39. }
  40. public void testNamedVoiceVariant()
  41. {
  42. VoiceVariant variant = VoiceVariant.parseVoiceVariant("klatt1");
  43. assertThat(variant.variant, is("klatt1"));
  44. assertThat(variant.gender, is(SpeechSynthesis.GENDER_UNSPECIFIED));
  45. assertThat(variant.age, is(SpeechSynthesis.AGE_ANY));
  46. assertThat(variant.toString(), is("klatt1"));
  47. }
  48. public void testMaleVoiceVariantYoung()
  49. {
  50. VoiceVariant variant = VoiceVariant.parseVoiceVariant("male-young");
  51. assertThat(variant.variant, is(nullValue()));
  52. assertThat(variant.gender, is(SpeechSynthesis.GENDER_MALE));
  53. assertThat(variant.age, is(SpeechSynthesis.AGE_YOUNG));
  54. assertThat(variant.toString(), is("male-young"));
  55. }
  56. public void testFemaleVoiceVariantYoung()
  57. {
  58. VoiceVariant variant = VoiceVariant.parseVoiceVariant("female-young");
  59. assertThat(variant.variant, is(nullValue()));
  60. assertThat(variant.gender, is(SpeechSynthesis.GENDER_FEMALE));
  61. assertThat(variant.age, is(SpeechSynthesis.AGE_YOUNG));
  62. assertThat(variant.toString(), is("female-young"));
  63. }
  64. public void testNamedVoiceVariantYoung()
  65. {
  66. VoiceVariant variant = VoiceVariant.parseVoiceVariant("klatt2-young");
  67. assertThat(variant.variant, is("klatt2"));
  68. assertThat(variant.gender, is(SpeechSynthesis.GENDER_UNSPECIFIED));
  69. assertThat(variant.age, is(SpeechSynthesis.AGE_YOUNG));
  70. assertThat(variant.toString(), is("klatt2-young"));
  71. }
  72. public void testMaleVoiceVariantOld()
  73. {
  74. VoiceVariant variant = VoiceVariant.parseVoiceVariant("male-old");
  75. assertThat(variant.variant, is(nullValue()));
  76. assertThat(variant.gender, is(SpeechSynthesis.GENDER_MALE));
  77. assertThat(variant.age, is(SpeechSynthesis.AGE_OLD));
  78. assertThat(variant.toString(), is("male-old"));
  79. }
  80. public void testFemaleVoiceVariantOld()
  81. {
  82. VoiceVariant variant = VoiceVariant.parseVoiceVariant("female-old");
  83. assertThat(variant.variant, is(nullValue()));
  84. assertThat(variant.gender, is(SpeechSynthesis.GENDER_FEMALE));
  85. assertThat(variant.age, is(SpeechSynthesis.AGE_OLD));
  86. assertThat(variant.toString(), is("female-old"));
  87. }
  88. public void testNamedVoiceVariantOld()
  89. {
  90. VoiceVariant variant = VoiceVariant.parseVoiceVariant("klatt3-old");
  91. assertThat(variant.variant, is("klatt3"));
  92. assertThat(variant.gender, is(SpeechSynthesis.GENDER_UNSPECIFIED));
  93. assertThat(variant.age, is(SpeechSynthesis.AGE_OLD));
  94. assertThat(variant.toString(), is("klatt3-old"));
  95. }
  96. }