azure_stt 0.1.1 → 0.2.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: 327424cc1662edd29b58e2aa1a47d71e28fc0a0039c6f86dcdfb869e4132c754
4
+ data.tar.gz: b00b94fdf99456649a00d1e2f0a1fc31753da6dde620599f6d84259a8e24f059
5
5
  SHA512:
6
- metadata.gz: 31c95c98f624d649c42f4c151fe1f5e8136e44e45835882ea2d1df96e693666d20646a8d4f38516330f07991671bcd5af879fb4797a63befb07ece5ae1834ef2
7
- data.tar.gz: 1b27f2a736e42bde420385da71d3c1a89e5112f8c05ac0cae83a4d2ed09c845f08d093e999226eb83268c0284955c40ddc98d27ea8c08c4a35a6dd3cca94cbbe
6
+ metadata.gz: 1bdf8e794a70a14453a47d7bd55a0374aace466a39fb5c80115a7d2265b73a6cbfbd9ab5df706652ad4bde5c3c10aed8b577575a45e92a3b77d0d61f90c99aad
7
+ data.tar.gz: 6febf5be3e311092e1d6cf23746b9d22633607d6479bd2c9fd4b52ade015b833f8ef6f33d07b7307665ae0a6be00c34f6bd8e4bee4a4f1ff6c4abb7a63f5c055
data/CHANGELOG.md CHANGED
@@ -5,6 +5,22 @@ 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
+ ## [Released]
11
+
12
+ ## [0.2.0] - 2021-07-01
13
+
14
+ ### Added
15
+
16
+ * Delete a transcription
17
+
18
+ ## [0.1.1] - 2021-06-24
19
+
20
+ ### Fixed
21
+
22
+ * dry-struct dependency in the gemspec
23
+
8
24
  ## [0.1.0] - 2021-06-24
9
25
 
10
26
  ### Added
@@ -15,14 +31,10 @@ The format is based on [Keep a Changelog][Keep a Changelog] and this project adh
15
31
 
16
32
  ---
17
33
 
18
- ## [Released]
19
-
20
- ---
21
-
22
34
  <!-- Links -->
23
35
  [Keep a Changelog]: https://keepachangelog.com/
24
36
  [Semantic Versioning]: https://semver.org/
25
37
 
26
38
  <!-- Versions -->
27
39
  [Unreleased]: https://github.com/PerfectMemory/azure_stt/compare/next
28
- [Released]: https://github.com/PerfectMemory/azure_stt/releases
40
+ [Released]: https://github.com/PerfectMemory/azure_stt/releases
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (6.1.3.2)
4
+ activesupport (6.1.4)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.2)
6
6
  i18n (>= 1.6, < 2)
7
7
  minitest (>= 5.1)
@@ -24,7 +24,7 @@ GEM
24
24
  dry-configurable (~> 0.1, >= 0.1.3)
25
25
  dry-core (0.6.0)
26
26
  concurrent-ruby (~> 1.0)
27
- dry-inflector (0.2.0)
27
+ dry-inflector (0.2.1)
28
28
  dry-logic (1.2.0)
29
29
  concurrent-ruby (~> 1.0)
30
30
  dry-core (~> 0.5, >= 0.5)
@@ -78,7 +78,7 @@ GEM
78
78
  diff-lcs (>= 1.2.0, < 2.0)
79
79
  rspec-support (~> 3.10.0)
80
80
  rspec-support (3.10.2)
81
- rubocop (1.17.0)
81
+ rubocop (1.18.1)
82
82
  parallel (~> 1.10)
83
83
  parser (>= 3.0.0.0)
84
84
  rainbow (>= 2.2.2, < 4.0)
@@ -92,8 +92,8 @@ GEM
92
92
  rubocop-performance (1.11.3)
93
93
  rubocop (>= 1.7.0, < 2.0)
94
94
  rubocop-ast (>= 0.4.0)
95
- rubocop-rake (0.5.1)
96
- rubocop
95
+ rubocop-rake (0.6.0)
96
+ rubocop (~> 1.0)
97
97
  rubocop-rspec (2.4.0)
98
98
  rubocop (~> 1.0)
99
99
  rubocop-ast (>= 1.1.0)
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.
@@ -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
  #
@@ -80,6 +80,21 @@ module AzureSTT
80
80
  end
81
81
  end
82
82
 
83
+ #
84
+ # Delete an API transcription with a given ID. The transcription will not
85
+ # exist anymore in the API, therefore you won't be able to retrieve it.
86
+ #
87
+ # @see https://westus.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-0/operations/DeleteTranscription
88
+ #
89
+ # @param [String] id The id of the transcription in the API
90
+ #
91
+ # @return [Boolean] true if the transcription had been deleted, raises
92
+ # an error else
93
+ #
94
+ def delete_transcription(id)
95
+ client.delete_transcription(id)
96
+ end
97
+
83
98
  private
84
99
 
85
100
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AzureStt
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  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.2.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: 2021-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct