README.md in azure_stt-0.1.1 vs README.md in azure_stt-0.2.0

- old
+ new

@@ -1,7 +1,8 @@ # azure_stt +[![Gem Version](https://badge.fury.io/rb/azure_stt.svg)](https://badge.fury.io/rb/azure_stt) [![CI](https://github.com/PerfectMemory/azure_stt/actions/workflows/ci.yml/badge.svg)](https://github.com/PerfectMemory/azure_stt/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/github/PerfectMemory/azure_stt/badge.svg)](https://coveralls.io/github/PerfectMemory/azure_stt) [![Maintainability](https://api.codeclimate.com/v1/badges/375190d3122da56a9fe1/maintainability)](https://codeclimate.com/github/PerfectMemory/azure_stt/maintainability) API Wrapper for the [Microsoft Azure Speech Services Speech-to-text REST API 3.0](https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-speech-to-text) (Cognitive Services). @@ -30,11 +31,11 @@ To be able to use the gem, you must have a subscription key. You can generate one on your Azure account. * If you don't have an Azure account, you can create one for free on [this page](https://azure.microsoft.com/en-us/free/). -* Once logged on your [Azure portal](https://portal.azure.com/), subscribe to SpeechServices in Microsoft Cognitive Service. +* Once logged on your [Azure portal](https://portal.azure.com/), subscribe to Speech in Microsoft Cognitive Services. * You will find two subscription keys available in 'RESOURCE MANAGEMENT > Keys' ('KEY 1' and 'KEY 2'). ## Usage ### Configuration @@ -59,11 +60,11 @@ ```ruby session = AzureSTT::Session.new(region: 'your_region', subscription_key: 'your_key') ``` -### start a transcription +### Start a transcription ```ruby require 'azure_stt' properties = { @@ -113,14 +114,63 @@ result = transcription.results.first puts result.text end ``` +### Delete a transcription + +```ruby +require 'azure_stt' + +session = AzureSTT::Session.new + +transcription = session.delete_transcription('your_transcription_id') +``` + +The API doesn't seem to send 404 errors when the id is unknown, but always send a 204 response. +So the `Session#delete_transcription` returns `true` even when the transcription didn't exist. + +### Starting a transcription, fetching the results and deleting the transcription + +```ruby +require 'azure_stt' + +session = AzureSTT::Session.new + +properties = { + "diarizationEnabled" => false, + "wordLevelTimestampsEnabled" => false, + "punctuationMode" => "DictatedAndAutomatic", + "profanityFilterMode" => "Masked" +} + +content_urls = [ 'https://path.com/audio.ogg' ] + +session = AzureSTT::Session.new + +transcription = session.create_transcription( + content_urls: content_urls, + properties: properties, + locale: 'en-US', + display_name: 'The name of the transcription') + +id = transcription.id + +while(!transcription.finished?) do + sleep(30) + transcription = session.get_transcription(id) +end + +if(transcription.succeeded?) + puts transcription.results.first.text +end + +session.delete_transcription(id) +``` + ## Development 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. - -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). ## Contributing 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.