azure_stt 0.1.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a84b9a4ebc166d7d641c3f2d438f586e211747200b8f16c55114be615d3fc95
4
- data.tar.gz: cb621eb69dc8621e027ab73c0274bf65869ab91116e6da3660cef9a1e0606b6e
3
+ metadata.gz: 71c2c80aa3d7493e1dd60052ac4e83a7e9351eb367c03202a0d0991120c7ebc4
4
+ data.tar.gz: 55dc37a5463f36425d37a9b5eb2a2416d00198628bdf5678e8761df7bf4ec7dc
5
5
  SHA512:
6
- metadata.gz: 31c95c98f624d649c42f4c151fe1f5e8136e44e45835882ea2d1df96e693666d20646a8d4f38516330f07991671bcd5af879fb4797a63befb07ece5ae1834ef2
7
- data.tar.gz: 1b27f2a736e42bde420385da71d3c1a89e5112f8c05ac0cae83a4d2ed09c845f08d093e999226eb83268c0284955c40ddc98d27ea8c08c4a35a6dd3cca94cbbe
6
+ metadata.gz: 40e10ff4e3fb07c4521b6fda6809853df234748442c41d8f8bd2535b75a8ff6c759377d90799daec02545f1586cba48aafd6641972029b832bd241afad6f8347
7
+ data.tar.gz: f6da9bea5a7becff8efcc2a953be8f6fc1b98ffeb7d77ecdab910aa8db1aa91ae2f5c4e61008b0c4269072c968ed7a7b721a4b7df675a8a5262ea0a09d5a1785
@@ -10,13 +10,16 @@ jobs:
10
10
  test:
11
11
 
12
12
  runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['3.1', '3.0', '2.7', '2.6']
13
16
 
14
17
  steps:
15
- - uses: actions/checkout@v2
16
- - name: Set up Ruby
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Ruby ${{ matrix.ruby-version }}
17
20
  uses: ruby/setup-ruby@v1
18
21
  with:
19
- ruby-version: 2.6
22
+ ruby-version: ${{ matrix.ruby-version }}
20
23
  - name: Install dependencies
21
24
  run: bundle install
22
25
  - name: Run tests
data/.gitignore CHANGED
@@ -45,9 +45,9 @@ build-iPhoneSimulator/
45
45
 
46
46
  # for a library or gem, you might want to ignore these files since the code is
47
47
  # intended to run in multiple environments; otherwise, check them in:
48
- # Gemfile.lock
49
- # .ruby-version
50
48
  # .ruby-gemset
49
+ Gemfile.lock
50
+ .ruby-version
51
51
 
52
52
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
53
  .rvmrc
data/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ The format is based on [Keep a Changelog][Keep a Changelog] and this project adh
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ---
9
+
10
+ ## [0.3.0] - 2022-10-19
11
+
12
+ ### Modified
13
+
14
+ - Compatibility with Ruby 3.1
15
+
16
+ ## [Released]
17
+
18
+ ## [0.2.0] - 2021-07-01
19
+
20
+ ### Added
21
+
22
+ * Delete a transcription
23
+
24
+ ## [0.1.1] - 2021-06-24
25
+
26
+ ### Fixed
27
+
28
+ * dry-struct dependency in the gemspec
29
+
8
30
  ## [0.1.0] - 2021-06-24
9
31
 
10
32
  ### Added
@@ -15,14 +37,10 @@ The format is based on [Keep a Changelog][Keep a Changelog] and this project adh
15
37
 
16
38
  ---
17
39
 
18
- ## [Released]
19
-
20
- ---
21
-
22
40
  <!-- Links -->
23
41
  [Keep a Changelog]: https://keepachangelog.com/
24
42
  [Semantic Versioning]: https://semver.org/
25
43
 
26
44
  <!-- Versions -->
27
45
  [Unreleased]: https://github.com/PerfectMemory/azure_stt/compare/next
28
- [Released]: https://github.com/PerfectMemory/azure_stt/releases
46
+ [Released]: https://github.com/PerfectMemory/azure_stt/releases
data/Gemfile CHANGED
@@ -3,10 +3,10 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gem 'dry-struct', '~> 1'
6
- gem 'httparty', '~> 0.17'
6
+ gem 'httparty', '~> 0.19'
7
7
 
8
8
  group :test do
9
- gem 'bundler', '~> 1.17'
9
+ gem 'bundler', '~> 2'
10
10
  gem 'dotenv'
11
11
  gem 'factory_bot', '~> 6'
12
12
  gem 'faker', '~> 2'
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # azure_stt
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/azure_stt.svg)](https://badge.fury.io/rb/azure_stt)
3
4
  [![CI](https://github.com/PerfectMemory/azure_stt/actions/workflows/ci.yml/badge.svg)](https://github.com/PerfectMemory/azure_stt/actions/workflows/ci.yml)
4
5
  [![Coverage Status](https://coveralls.io/repos/github/PerfectMemory/azure_stt/badge.svg)](https://coveralls.io/github/PerfectMemory/azure_stt)
5
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/375190d3122da56a9fe1/maintainability)](https://codeclimate.com/github/PerfectMemory/azure_stt/maintainability)
@@ -32,7 +33,7 @@ To be able to use the gem, you must have a subscription key.
32
33
  You can generate one on your Azure account.
33
34
 
34
35
  * If you don't have an Azure account, you can create one for free on [this page](https://azure.microsoft.com/en-us/free/).
35
- * Once logged on your [Azure portal](https://portal.azure.com/), subscribe to SpeechServices in Microsoft Cognitive Service.
36
+ * Once logged on your [Azure portal](https://portal.azure.com/), subscribe to Speech in Microsoft Cognitive Services.
36
37
  * You will find two subscription keys available in 'RESOURCE MANAGEMENT > Keys' ('KEY 1' and 'KEY 2').
37
38
 
38
39
  ## Usage
@@ -61,7 +62,7 @@ Finally, the class `AzureSTT::Session` uses by the default the values from the c
61
62
  session = AzureSTT::Session.new(region: 'your_region', subscription_key: 'your_key')
62
63
  ```
63
64
 
64
- ### start a transcription
65
+ ### Start a transcription
65
66
 
66
67
  ```ruby
67
68
  require 'azure_stt'
@@ -115,12 +116,61 @@ if transcription.succeeded?
115
116
  end
116
117
  ```
117
118
 
119
+ ### Delete a transcription
120
+
121
+ ```ruby
122
+ require 'azure_stt'
123
+
124
+ session = AzureSTT::Session.new
125
+
126
+ transcription = session.delete_transcription('your_transcription_id')
127
+ ```
128
+
129
+ The API doesn't seem to send 404 errors when the id is unknown, but always send a 204 response.
130
+ So the `Session#delete_transcription` returns `true` even when the transcription didn't exist.
131
+
132
+ ### Starting a transcription, fetching the results and deleting the transcription
133
+
134
+ ```ruby
135
+ require 'azure_stt'
136
+
137
+ session = AzureSTT::Session.new
138
+
139
+ properties = {
140
+ "diarizationEnabled" => false,
141
+ "wordLevelTimestampsEnabled" => false,
142
+ "punctuationMode" => "DictatedAndAutomatic",
143
+ "profanityFilterMode" => "Masked"
144
+ }
145
+
146
+ content_urls = [ 'https://path.com/audio.ogg' ]
147
+
148
+ session = AzureSTT::Session.new
149
+
150
+ transcription = session.create_transcription(
151
+ content_urls: content_urls,
152
+ properties: properties,
153
+ locale: 'en-US',
154
+ display_name: 'The name of the transcription')
155
+
156
+ id = transcription.id
157
+
158
+ while(!transcription.finished?) do
159
+ sleep(30)
160
+ transcription = session.get_transcription(id)
161
+ end
162
+
163
+ if(transcription.succeeded?)
164
+ puts transcription.results.first.text
165
+ end
166
+
167
+ session.delete_transcription(id)
168
+ ```
169
+
118
170
  ## Development
119
171
 
120
172
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
121
173
 
122
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
123
-
124
174
  ## Contributing
125
175
 
126
176
  Bug reports and pull requests are welcome on GitHub at https://github.com/PerfectMemory/azure_stt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
data/azure_stt.gemspec CHANGED
@@ -26,4 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.required_ruby_version = '>= 2.6'
27
27
  spec.add_dependency 'dry-struct', '~> 1'
28
28
  spec.add_dependency 'httparty', '~> 0.17'
29
+ spec.metadata = {
30
+ 'rubygems_mfa_required' => 'true'
31
+ }
29
32
  end
@@ -75,6 +75,20 @@ module AzureSTT
75
75
  results.parsed_response['values']
76
76
  end
77
77
 
78
+ #
79
+ # Delete a transcription with a given ID
80
+ #
81
+ # @param [String] id The id of the transcription in the API
82
+ #
83
+ # @return [Boolean] true if the transcription had been deleted, raises an error else
84
+ #
85
+ def delete_transcription(id)
86
+ response = self.class.delete("/transcriptions/#{id}", headers: headers)
87
+ handle_response(response)
88
+
89
+ true
90
+ end
91
+
78
92
  #
79
93
  # Get an array containing the files for a given transcription
80
94
  #
@@ -1,4 +1,4 @@
1
- # frozen_String_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  module AzureSTT
4
4
  module Parsers
@@ -38,12 +38,10 @@ module AzureSTT
38
38
  #
39
39
  def create_transcription(content_urls:, properties:, locale:, display_name:)
40
40
  transcription_hash = client.create_transcription(
41
- {
42
- contentUrls: content_urls,
43
- properties: properties,
44
- locale: locale,
45
- displayName: display_name
46
- }
41
+ contentUrls: content_urls,
42
+ properties: properties,
43
+ locale: locale,
44
+ displayName: display_name
47
45
  )
48
46
  build_transcription_from_hash(transcription_hash)
49
47
  end
@@ -80,6 +78,21 @@ module AzureSTT
80
78
  end
81
79
  end
82
80
 
81
+ #
82
+ # Delete an API transcription with a given ID. The transcription will not
83
+ # exist anymore in the API, therefore you won't be able to retrieve it.
84
+ #
85
+ # @see https://westus.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-0/operations/DeleteTranscription
86
+ #
87
+ # @param [String] id The id of the transcription in the API
88
+ #
89
+ # @return [Boolean] true if the transcription had been deleted, raises
90
+ # an error else
91
+ #
92
+ def delete_transcription(id)
93
+ client.delete_transcription(id)
94
+ end
95
+
83
96
  private
84
97
 
85
98
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AzureStt
4
- VERSION = '0.1.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/azure_stt.rb CHANGED
@@ -15,6 +15,6 @@ require_relative 'azure_stt/parsers'
15
15
  require_relative 'azure_stt/session'
16
16
 
17
17
  AzureSTT.configure do |config|
18
- config.subscription_key = ENV['SUBSCRIPTION_KEY']
19
- config.region = ENV['REGION']
18
+ config.subscription_key = ENV.fetch('SUBSCRIPTION_KEY', nil)
19
+ config.region = ENV.fetch('REGION', 'uscentral')
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azure_stt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - François Pouly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -45,14 +45,12 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - ".github/dependabot.yml"
49
48
  - ".github/workflows/ci.yml"
50
49
  - ".gitignore"
51
50
  - ".rubocop.yml"
52
51
  - CHANGELOG.md
53
52
  - CODE_OF_CONDUCT.md
54
53
  - Gemfile
55
- - Gemfile.lock
56
54
  - LICENSE
57
55
  - README.md
58
56
  - Rakefile
@@ -135,7 +133,8 @@ files:
135
133
  homepage: https://github.com/PerfectMemory/azure_stt
136
134
  licenses:
137
135
  - MIT
138
- metadata: {}
136
+ metadata:
137
+ rubygems_mfa_required: 'true'
139
138
  post_install_message:
140
139
  rdoc_options: []
141
140
  require_paths:
@@ -151,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
150
  - !ruby/object:Gem::Version
152
151
  version: '0'
153
152
  requirements: []
154
- rubygems_version: 3.0.3
153
+ rubygems_version: 3.1.6
155
154
  signing_key:
156
155
  specification_version: 4
157
156
  summary: API Wrapper for the Microsoft Translator Text API 3.0
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: 'bundler'
4
- directory: '/'
5
- schedule:
6
- interval: 'daily'
data/Gemfile.lock DELETED
@@ -1,141 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- activesupport (6.1.3.2)
5
- concurrent-ruby (~> 1.0, >= 1.0.2)
6
- i18n (>= 1.6, < 2)
7
- minitest (>= 5.1)
8
- tzinfo (~> 2.0)
9
- zeitwerk (~> 2.3)
10
- addressable (2.7.0)
11
- public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.2)
13
- concurrent-ruby (1.1.9)
14
- crack (0.4.5)
15
- rexml
16
- diff-lcs (1.4.4)
17
- docile (1.4.0)
18
- dotenv (2.7.6)
19
- dry-configurable (0.12.1)
20
- concurrent-ruby (~> 1.0)
21
- dry-core (~> 0.5, >= 0.5.0)
22
- dry-container (0.8.0)
23
- concurrent-ruby (~> 1.0)
24
- dry-configurable (~> 0.1, >= 0.1.3)
25
- dry-core (0.6.0)
26
- concurrent-ruby (~> 1.0)
27
- dry-inflector (0.2.0)
28
- dry-logic (1.2.0)
29
- concurrent-ruby (~> 1.0)
30
- dry-core (~> 0.5, >= 0.5)
31
- dry-struct (1.4.0)
32
- dry-core (~> 0.5, >= 0.5)
33
- dry-types (~> 1.5)
34
- ice_nine (~> 0.11)
35
- dry-types (1.5.1)
36
- concurrent-ruby (~> 1.0)
37
- dry-container (~> 0.3)
38
- dry-core (~> 0.5, >= 0.5)
39
- dry-inflector (~> 0.1, >= 0.1.2)
40
- dry-logic (~> 1.0, >= 1.0.2)
41
- factory_bot (6.2.0)
42
- activesupport (>= 5.0.0)
43
- faker (2.18.0)
44
- i18n (>= 1.6, < 2)
45
- hashdiff (1.0.1)
46
- httparty (0.18.1)
47
- mime-types (~> 3.0)
48
- multi_xml (>= 0.5.2)
49
- i18n (1.8.10)
50
- concurrent-ruby (~> 1.0)
51
- ice_nine (0.11.2)
52
- mime-types (3.3.1)
53
- mime-types-data (~> 3.2015)
54
- mime-types-data (3.2021.0225)
55
- minitest (5.14.4)
56
- multi_xml (0.6.0)
57
- parallel (1.20.1)
58
- parser (3.0.1.1)
59
- ast (~> 2.4.1)
60
- public_suffix (4.0.6)
61
- rainbow (3.0.0)
62
- rake (13.0.3)
63
- regexp_parser (2.1.1)
64
- rexml (3.2.5)
65
- rspec (3.10.0)
66
- rspec-core (~> 3.10.0)
67
- rspec-expectations (~> 3.10.0)
68
- rspec-mocks (~> 3.10.0)
69
- rspec-core (3.10.1)
70
- rspec-support (~> 3.10.0)
71
- rspec-expectations (3.10.1)
72
- diff-lcs (>= 1.2.0, < 2.0)
73
- rspec-support (~> 3.10.0)
74
- rspec-its (1.3.0)
75
- rspec-core (>= 3.0.0)
76
- rspec-expectations (>= 3.0.0)
77
- rspec-mocks (3.10.2)
78
- diff-lcs (>= 1.2.0, < 2.0)
79
- rspec-support (~> 3.10.0)
80
- rspec-support (3.10.2)
81
- rubocop (1.17.0)
82
- parallel (~> 1.10)
83
- parser (>= 3.0.0.0)
84
- rainbow (>= 2.2.2, < 4.0)
85
- regexp_parser (>= 1.8, < 3.0)
86
- rexml
87
- rubocop-ast (>= 1.7.0, < 2.0)
88
- ruby-progressbar (~> 1.7)
89
- unicode-display_width (>= 1.4.0, < 3.0)
90
- rubocop-ast (1.7.0)
91
- parser (>= 3.0.1.1)
92
- rubocop-performance (1.11.3)
93
- rubocop (>= 1.7.0, < 2.0)
94
- rubocop-ast (>= 0.4.0)
95
- rubocop-rake (0.5.1)
96
- rubocop
97
- rubocop-rspec (2.4.0)
98
- rubocop (~> 1.0)
99
- rubocop-ast (>= 1.1.0)
100
- ruby-progressbar (1.11.0)
101
- simplecov (0.21.2)
102
- docile (~> 1.1)
103
- simplecov-html (~> 0.11)
104
- simplecov_json_formatter (~> 0.1)
105
- simplecov-html (0.12.3)
106
- simplecov-lcov (0.8.0)
107
- simplecov_json_formatter (0.1.3)
108
- tzinfo (2.0.4)
109
- concurrent-ruby (~> 1.0)
110
- unicode-display_width (2.0.0)
111
- webmock (3.13.0)
112
- addressable (>= 2.3.6)
113
- crack (>= 0.3.2)
114
- hashdiff (>= 0.4.0, < 2.0.0)
115
- yard (0.9.26)
116
- zeitwerk (2.4.2)
117
-
118
- PLATFORMS
119
- ruby
120
-
121
- DEPENDENCIES
122
- bundler (~> 1.17)
123
- dotenv
124
- dry-struct (~> 1)
125
- factory_bot (~> 6)
126
- faker (~> 2)
127
- httparty (~> 0.17)
128
- rake (~> 13.0)
129
- rspec (~> 3)
130
- rspec-its
131
- rubocop
132
- rubocop-performance
133
- rubocop-rake
134
- rubocop-rspec
135
- simplecov
136
- simplecov-lcov
137
- webmock
138
- yard
139
-
140
- BUNDLED WITH
141
- 1.17.3