-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcall-recording_transcribe_voicebase_url.rb
47 lines (35 loc) · 1.16 KB
/
call-recording_transcribe_voicebase_url.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!ruby
require 'multi_json'
require 'ringcentral_sdk'
require 'voicebase'
require 'pp'
# Set your credentials in the .env file
# Use the credentials_sample.env.txt file as a scaffold
client = RingCentralSdk::REST::Client.new do |config|
config.load_env = true
end
def transcribe_recordings(rcsdk, vbsdk)
# Retrieve voice call log records with recordings
response = rcsdk.http.get do |req|
params = { type: 'Voice', withRecording: 'True', dateFrom: '2015-01-01' }
req.url 'account/~/extension/~/call-log', params
end
# Save recording and metadata for each call log record
if response.body.key? 'records'
response.body['records'].each_with_index do |record, _|
next unless
record.key?('recording') &&
record['recording'].key?('contentUri')
content_uri = record['recording']['contentUri'].to_s
content_uri += '?access_token=' + rcsdk.token.token.to_s
response_vb = vbsdk.upload_media mediaUrl: content_uri.to_s
pp response_vb.body
end
end
end
vbsdk = VoiceBase::V1::Client.new(
ENV['RINGCENTRAL_DEMO_VB_API_KEY'],
ENV['RINGCENTRAL_DEMO_VB_PASSWORD']
)
transcribe_recordings(client, vbsdk)
puts 'DONE'