1
2
3
4
5
6
7 package com.octo.captcha.component.sound.soundconfigurator;
8
9 import com.octo.captcha.CaptchaException;
10
11 /***
12 * Implmenentation for a FreeTTS configuration
13 *
14 * @author Benoit Doumas
15 * @version 1.0
16 */
17 public class FreeTTSSoundConfigurator implements SoundConfigurator {
18 String name;
19
20 String location;
21
22 float volume;
23
24 float pitch;
25
26 float rate;
27
28 /***
29 * Contructor for a FreeTTS configuration
30 *
31 * @param name Name of the sound
32 * @param location Package containing the sound defined by name
33 * @param volume Between 0 and 1.0
34 * @param pitch Level of the sound (hetz), between 50 and 250, normal 100
35 * @param rate Words per minute, between 1 and 999, normal 150
36 */
37 public FreeTTSSoundConfigurator(String name, String location, float volume, float pitch,
38 float rate) {
39 this.name = name;
40
41 this.location = location;
42
43 if ((volume <= 1.0) && (volume >= 0)) {
44 this.volume = volume;
45 } else {
46 throw new CaptchaException("Volume is between 0 and 1.0");
47 }
48
49 if ((pitch <= 250) && (pitch >= 50)) {
50 this.pitch = pitch;
51 } else {
52 throw new CaptchaException("Pitch is between 50 and 250");
53 }
54
55 if ((rate < 1000) && (rate > 0)) {
56 this.rate = rate;
57 } else {
58 throw new CaptchaException("Rate is between 1 and 999");
59 }
60
61 }
62
63 /***
64 * @see com.octo.captcha.component.sound.soundconfigurator.SoundConfigurator#getVolume()
65 */
66 public float getVolume() {
67 return this.volume;
68 }
69
70 /***
71 * @see com.octo.captcha.component.sound.soundconfigurator.SoundConfigurator#getPitch()
72 */
73 public float getPitch() {
74 return this.pitch;
75 }
76
77 /***
78 * @see com.octo.captcha.component.sound.soundconfigurator.SoundConfigurator#getName()
79 */
80 public String getName() {
81 return this.name;
82 }
83
84 /***
85 * @see com.octo.captcha.component.sound.soundconfigurator.SoundConfigurator#getRate()
86 */
87 public float getRate() {
88 return this.rate;
89 }
90
91 /***
92 * @see com.octo.captcha.component.sound.soundconfigurator.SoundConfigurator#getLocation()
93 */
94 public String getLocation() {
95 return this.location;
96 }
97
98 }