happyscribe 1.0.1 → 1.0.3
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +26 -8
- data/happyscribe-1.0.1.gem +0 -0
- data/happyscribe-1.0.2.gem +0 -0
- data/happyscribe.gemspec +3 -3
- data/lib/happyscribe.rb +41 -12
- data/lib/happyscribe/version.rb +1 -1
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de5530dba1327e61cc5c8e14dc49a5267d02f8d8b5281cf5ab8603b63966c699
|
4
|
+
data.tar.gz: 503bab852d4b9e9cb064a4c7859a8237b064380f717fb7a4b54511815329a4e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a847552ceefabf48688c375f8a874f5d519e2a65944a344953e4fa4228a95d9fc1ebf1d8f970fea6d0224a52243be990fcb19857d8f2db37050b320616a12316
|
7
|
+
data.tar.gz: 193778eeb0f75b70dcf68dd1394b17caa7c46e6e640646bfa2a6cf3afb126daa2eb6caca3f5a9d3b47ac83cbe0ac3075e9130addab9d9985cea25bf82dcd240b
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ GEM
|
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.4.4)
|
10
|
-
rake (
|
10
|
+
rake (13.0.1)
|
11
11
|
rspec (3.9.0)
|
12
12
|
rspec-core (~> 3.9.0)
|
13
13
|
rspec-expectations (~> 3.9.0)
|
@@ -28,7 +28,7 @@ PLATFORMS
|
|
28
28
|
DEPENDENCIES
|
29
29
|
bundler (~> 2.0)
|
30
30
|
happyscribe!
|
31
|
-
rake (~>
|
31
|
+
rake (~> 13.0)
|
32
32
|
rspec (~> 3.0)
|
33
33
|
|
34
34
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Happyscribe client for Ruby
|
2
|
-
This is a
|
2
|
+
This is a small NON-OFFICIAL gem based on happyscribes api (https://dev.happyscribe.co/). It works out of the box and makes the usage of the api much easier ;-)
|
3
3
|
|
4
4
|
## dependencies
|
5
5
|
because no one love to have 10k of dependencies, this gem uses only: net/http,uri,json and securerandom. so do not worry about the size of the gem.
|
@@ -29,43 +29,61 @@ require "happyscribe"
|
|
29
29
|
```
|
30
30
|
|
31
31
|
### nota bene
|
32
|
-
all the functions
|
32
|
+
all the functions send you back a parsed json (array) with the response of the api.
|
33
33
|
|
34
34
|
### some Ruby please !
|
35
35
|
create an instance:
|
36
36
|
```ruby
|
37
37
|
instance = Happyscribe::Transcript.new(my_api_token)
|
38
|
+
#return nothing
|
38
39
|
```
|
40
|
+
|
41
|
+
#### API
|
39
42
|
create a transcription. you can use all of the avaiable language codes (https://dev.happyscribe.co/#languages)
|
40
43
|
```ruby
|
41
|
-
instance.create(public_url_to_audio,"fr-FR")
|
44
|
+
response = instance.create(public_url_to_audio,"fr-FR")
|
45
|
+
#return: dictionnary with the id,.... (the id is the only thing that matter)
|
42
46
|
```
|
43
47
|
Good to know: if you are working with ActiveStorage, you can create a public_url with url_for()
|
44
48
|
|
45
49
|
retrieve all the transcriptions
|
46
50
|
```ruby
|
47
|
-
instance.list
|
51
|
+
response = instance.list
|
52
|
+
#return: a dictionnary with a key "results" where all the transcriptions are listed
|
48
53
|
```
|
49
|
-
retrieve
|
54
|
+
retrieve a transcription
|
50
55
|
```ruby
|
51
56
|
instance.retrieve(transcription_id)
|
57
|
+
#return: a dictionnary with everything about the transcriptions (status,....)
|
52
58
|
```
|
53
59
|
create an export
|
54
60
|
```ruby
|
55
|
-
instance.create_export(transcription_id, format,show_speakers,show_comments,show_highlights)
|
61
|
+
response = instance.create_export(transcription_id, format,show_speakers,show_comments,show_highlights)
|
56
62
|
# by default, format="txt", show_speakers,show_comments,... = false
|
57
63
|
# so you can just do
|
58
|
-
instance.create_export(transcription_id, format)
|
64
|
+
response = instance.create_export(transcription_id, format)
|
65
|
+
#return: a dictionnary with the id of the export and other informations. NB: you can't list all the exports, so do not lose the id ;-)
|
59
66
|
```
|
60
67
|
|
61
68
|
retrieve an export
|
62
69
|
```ruby
|
63
70
|
instance.retrieve_export(export_id)
|
71
|
+
#return: a dictionnary , with a link to an attachment that you can download.
|
72
|
+
```
|
73
|
+
|
74
|
+
#### Magic function
|
75
|
+
because we only want to have a string of the transcription, there is a function that creates the export, retrieve the export when it's ready, download the attachment and return it in utf-8.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
instance.export_in_txt(transcription_id)
|
79
|
+
#return: a string with the transcription
|
64
80
|
```
|
81
|
+
|
65
82
|
## Contributing
|
66
83
|
|
67
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
84
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jbd0101/happyscribe. 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.
|
68
85
|
|
86
|
+
you can always star the project ;)
|
69
87
|
|
70
88
|
## License
|
71
89
|
|
Binary file
|
Binary file
|
data/happyscribe.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["jean-christophe bauduin"]
|
9
9
|
spec.email = [""]
|
10
10
|
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{the api of happyscribe is quite verbose, this ruby gem make it
|
11
|
+
spec.summary = %q{ruby gem for the api of happyscribe}
|
12
|
+
spec.description = %q{the api of happyscribe is quite verbose, this ruby gem make it easy ! take a look at the documentation on github ( https://github.com/jbd0101/happyscribe-client ) }
|
13
13
|
spec.homepage = "https://github.com/jbd0101/happyscribe-client"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
spec.add_development_dependency "bundler", "~> 2.0"
|
32
|
-
spec.add_development_dependency "rake", "~>
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
33
33
|
spec.add_development_dependency "rspec", "~> 3.0"
|
34
34
|
end
|
data/lib/happyscribe.rb
CHANGED
@@ -94,6 +94,31 @@ module Happyscribe
|
|
94
94
|
end
|
95
95
|
return JSON.parse response.body
|
96
96
|
end
|
97
|
+
def create_multiple_export(ids,format="txt",timestamps=false,speakers=false,comments=false,highlights=false)
|
98
|
+
uri = URI.parse("#{@base}/exports")
|
99
|
+
request = Net::HTTP::Post.new(uri)
|
100
|
+
request.content_type = "application/json"
|
101
|
+
request["Authorization"] = @auth
|
102
|
+
request.body = JSON.dump({
|
103
|
+
"export" => {
|
104
|
+
"format" => format,
|
105
|
+
"show_timestamps" => timestamps,
|
106
|
+
"show_speakers" => speakers,
|
107
|
+
"show_comments" => comments,
|
108
|
+
"show_highlights" => highlights,
|
109
|
+
"transcription_ids" => ids
|
110
|
+
}
|
111
|
+
})
|
112
|
+
|
113
|
+
req_options = {
|
114
|
+
use_ssl: uri.scheme == "https",
|
115
|
+
}
|
116
|
+
|
117
|
+
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
|
118
|
+
http.request(request)
|
119
|
+
end
|
120
|
+
return JSON.parse response.body
|
121
|
+
end
|
97
122
|
def retrieve_export(export_id)
|
98
123
|
endpoint = "#{@base}/exports/#{export_id}"
|
99
124
|
uri = URI.parse(endpoint)
|
@@ -109,20 +134,24 @@ module Happyscribe
|
|
109
134
|
end
|
110
135
|
return JSON.parse response.body
|
111
136
|
end
|
112
|
-
def export_in_txt(
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
137
|
+
def export_in_txt(transcription_id)
|
138
|
+
transcription = retrieve transcription_id
|
139
|
+
if(transcription["state"]=="automatic_done")
|
140
|
+
export = create_export(transcription_id,"txt")["id"]
|
141
|
+
sleep(5)
|
142
|
+
while true
|
143
|
+
retrieved = retrieve_export(export)
|
144
|
+
if(retrieved["state"]=="ready")
|
145
|
+
break
|
146
|
+
else
|
147
|
+
sleep(2)
|
148
|
+
end
|
121
149
|
end
|
150
|
+
txt = URI.parse(retrieved["download_link"]).open.read.force_encoding("utf-8")
|
151
|
+
return txt
|
152
|
+
else
|
153
|
+
raise "The transcription is not ready"
|
122
154
|
end
|
123
|
-
txt = URI.parse(retrieved["download_link"]).open.read.force_encoding("utf-8")
|
124
|
-
return txt
|
125
|
-
|
126
155
|
end
|
127
156
|
end
|
128
157
|
end
|
data/lib/happyscribe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: happyscribe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jean-christophe bauduin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,8 +52,9 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description: the api of happyscribe is quite verbose, this ruby gem make it
|
56
|
-
|
55
|
+
description: 'the api of happyscribe is quite verbose, this ruby gem make it easy
|
56
|
+
! take a look at the documentation on github ( https://github.com/jbd0101/happyscribe-client
|
57
|
+
) '
|
57
58
|
email:
|
58
59
|
- ''
|
59
60
|
executables: []
|
@@ -73,6 +74,8 @@ files:
|
|
73
74
|
- bin/setup
|
74
75
|
- happyscribe-0.2.0.gem
|
75
76
|
- happyscribe-1.0.0.gem
|
77
|
+
- happyscribe-1.0.1.gem
|
78
|
+
- happyscribe-1.0.2.gem
|
76
79
|
- happyscribe.gemspec
|
77
80
|
- lib/happyscribe.rb
|
78
81
|
- lib/happyscribe/version.rb
|
@@ -102,5 +105,5 @@ requirements: []
|
|
102
105
|
rubygems_version: 3.0.4
|
103
106
|
signing_key:
|
104
107
|
specification_version: 4
|
105
|
-
summary:
|
108
|
+
summary: ruby gem for the api of happyscribe
|
106
109
|
test_files: []
|