yandex_speech_api 1.1.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
- module YandexSpeechApi
4
-
5
- # @example Valid Usage
6
- # Voice.new('Oksana') # ==> instance of voice class
7
- #
8
- # @example Bad Usage
9
- # Voice.new(:bill) # ==> VoiceNotAllowed exception
10
-
11
- class Voice
12
-
13
- ##
14
- # List of allowed voices
15
- #
16
- # @return [Array<String>]
17
-
18
- def self.list
19
- %i(jane oksana alyss omazh zahar ermil)
20
- end
21
-
22
- # @return [Symbol]
23
- # possible values: :jane, :oksana, :alyss, :omazh, :zahar, :ermil
24
-
25
- attr_reader :name
26
-
27
- def initialize(voice)
28
- @name = voice.downcase.to_sym
29
- raise VoiceNotAllowed, voice unless voice_known? @name
30
- end
31
-
32
- private
33
-
34
- def voice_known?(name)
35
- Voice.list.include? name
36
- end
37
-
38
- ##
39
- # Raised when unknown voice was selected.
40
-
41
- class VoiceNotAllowed < YandexSpeechError
42
- def initialize(voice)
43
- super "Voice '#{voice}' not allowed for usage. To see list of allowed voices use Voice#list" end; end
44
- end # class Voice
45
- end # module YandexSpeechApi
@@ -1,34 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module YandexSpeechApi
6
- describe Emotion do
7
- context '#new' do
8
- it 'raises an exception for unknown emotion' do
9
- expect { described_class.new :some_random_emotion }
10
- .to raise_exception described_class::EmotionNotAllowed
11
- end
12
-
13
- it 'creates object instance when emotion param is symbol' do
14
- expect(described_class.new(:good))
15
- .to be_instance_of Emotion
16
- end
17
-
18
- it 'creates object instance when emotion param is string' do
19
- expect(described_class.new('GOOD'))
20
- .to be_instance_of Emotion
21
- end
22
-
23
- it 'creates :good emotion without any exception' do
24
- expect { described_class.new :good }.to_not raise_exception
25
- end
26
- end # context #new
27
-
28
- context '#list' do
29
- it 'shows list of allowed emotions' do
30
- expect(described_class.list).to_not be_nil
31
- end
32
- end # context #list
33
- end # describe Emotion
34
- end # module YandexSpeechApi
@@ -1,30 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module YandexSpeechApi
6
- describe Format do
7
- context '#new' do
8
- it 'raises an exception for unknown format type' do
9
- expect { described_class.new :some_random_format }
10
- .to raise_exception described_class::FormatNotAllowed
11
- end
12
-
13
- it 'creates object instance when format param is symbol' do
14
- expect(described_class.new(:wav))
15
- .to be_instance_of Format
16
- end
17
-
18
- it 'creates object instance when format param is string' do
19
- expect(described_class.new('Wav'))
20
- .to be_instance_of Format
21
- end
22
- end # context #new
23
-
24
- context '#list' do
25
- it 'shows list of all possible formats' do
26
- expect(described_class.list).to_not be_nil
27
- end
28
- end # context #list
29
- end # describe Format
30
- end # module YandexSpeechApi
@@ -1,58 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module YandexSpeechApi
6
- describe Key do
7
- after :each do
8
- described_class.instance_variable_set :@global_key, nil
9
- end
10
-
11
- context '#global_key=(other)' do
12
- it 'raises an exception +other+ param is not present' do
13
- key = described_class.new :unknown
14
- expect { described_class.global_key = key }
15
- .to raise_error Key::InvalidGlobalKey
16
- end
17
- end # context '#global_key=(other)'
18
-
19
- context '#global_key' do
20
- it 'returns +false+ when global key not set' do
21
- expect(Key.global_key?).to be_falsey
22
- end
23
-
24
- it 'returns +true+ when global key set' do
25
- described_class.global_key = 'Secret Key'
26
- expect(Key.global_key?).to be_truthy
27
- end
28
- end # context '#global_key'
29
-
30
- context '#get' do
31
- it 'raises an exception for not defined (instance or global) key' do
32
- key = described_class.new :unknown
33
- expect { key.get }.to raise_error Key::KeyNotDefined
34
- end
35
-
36
- it 'not raises an exception when instance key defined' do
37
- key = described_class.new 'xxxxx-xxxxx-xxxxx-xxxxx-xxxxx'
38
- expect { key.get }.to_not raise_error
39
- end
40
-
41
- it 'not raises an exception when global key defined' do
42
- described_class.global_key = 'xxxxx-xxxxx-xxxxx-xxxxx-xxxxx'
43
- key = described_class.new :unknown
44
- expect { key.get }.to_not raise_error
45
- end
46
-
47
- it 'not raises an exception for any key instance when global key defined' do
48
- described_class.global_key = 'xxxxx-xxxxx-xxxxx-xxxxx-xxxxx'
49
-
50
- key = described_class.new :unknown
51
- key2 = described_class.new 'test key'
52
-
53
- expect { key.get }.to_not raise_error
54
- expect { key2.get }.to_not raise_error
55
- end
56
- end # context #get
57
- end # describe Key
58
- end # module YandexSpeechApi
@@ -1,36 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module YandexSpeechApi
6
- describe Language do
7
- context '#new' do
8
- it 'raises an exception for unknown language' do
9
- expect { described_class.new :wommi_lang }
10
- .to raise_exception described_class::UnknownLanguageError
11
- end
12
-
13
- it 'creates object instance when +language+ param is symbol' do
14
- expect{described_class.new(:ukrain)}.to_not raise_exception
15
- end
16
-
17
- it 'creates object instance when +language+ param is string' do
18
- expect{described_class.new('Ukrain')}.to_not raise_exception
19
- end
20
- end # context #new
21
-
22
- context '#allowed_languages' do
23
- it 'shows list of all possible languages' do
24
- expect(described_class.allowed_languages).to_not be_nil
25
- end
26
- end # context #allowed_languages
27
-
28
- context '#code' do
29
- it 'returns valid code for any class instance from #list' do
30
- sample = described_class.allowed_languages.sample
31
-
32
- expect{described_class.new(sample)}.to_not raise_exception
33
- end
34
- end # context #code
35
- end # describe Language
36
- end # module YandexSpeechApi
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module YandexSpeechApi
6
- describe MP3_Player do
7
- context '#init' do
8
- it 'raises an exception if mp3_player cannot been created' do
9
- allow(Helpers).to receive(:recognize_operation_system)
10
- .and_return 'unknown'
11
-
12
- expect{MP3_Player.init}.to raise_exception MP3_Player::UnknownOs
13
- end
14
-
15
- it 'creates an mp3_player instance' do
16
- allow(Helpers).to receive(:recognize_operation_system)
17
- .and_return :linux
18
-
19
- expect(MP3_Player.init).to be_instance_of MP3_Player::Linux_MP3_Player
20
- end
21
- end
22
- end # describe MP3_Player
23
- end # module YandexSpeechApi
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module YandexSpeechApi
6
- describe Speed do
7
- context '#new' do
8
- it 'raises an exception for unknown speed mode' do
9
- expect { described_class.new :lol }
10
- .to raise_exception described_class::SpeedModeNotAllowed
11
- end
12
-
13
- it 'creates object instance when +speed+ is a symbol' do
14
- expect(described_class.new(:slowest)).to be
15
- end
16
-
17
- it 'creates object instance when +speed+ is an integer' do
18
- expect(described_class.new(2.45)).to be
19
- end
20
-
21
- it 'raises an exception when +speed+ is not in allowed range' do
22
- expect { described_class.new 5000 }
23
- .to raise_exception described_class::SpeedValueNotInRange
24
- end
25
- end # context #new
26
-
27
- context '#list' do
28
- it 'shows list of allowed speed modes' do
29
- expect(described_class.modes).to_not be_nil
30
- end
31
- end # context #list
32
- end # describe Speed
33
- end # module YandexSpeechApi
@@ -1,28 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- module YandexSpeechApi
6
- describe Voice do
7
- context '#new' do
8
- it 'raises an exception for unknown voice' do
9
- expect { described_class.new :some_random_voice }
10
- .to raise_exception described_class::VoiceNotAllowed
11
- end
12
-
13
- it 'creates object instance when voice param is a symbol' do
14
- expect(described_class.new(:alyss)).to be_instance_of Voice
15
- end
16
-
17
- it 'creates object instance when voice param is a string' do
18
- expect(described_class.new('ALYSs')).to be_instance_of Voice
19
- end
20
- end # context #new
21
-
22
- context '#list' do
23
- it 'shows list of allowed voices' do
24
- expect(described_class.list).to_not be_nil
25
- end
26
- end # context #list
27
- end # describe Voice
28
- end # module YandexSpeechApi