@@ -11,6 +11,18 @@ def api_key
11
11
ENV . fetch ( "ASSEMBLYAI_API_KEY" )
12
12
end
13
13
14
+ # @return [String] AssemblyAI Base URL
15
+ def base_url
16
+ ENV . key? ( "ASSEMBLYAI_BASE_URL" ) ? ENV . fetch ( "ASSEMBLYAI_BASE_URL" ) : AssemblyAI ::Environment ::DEFAULT
17
+ end
18
+
19
+ def client
20
+ AssemblyAI ::Client . new (
21
+ api_key : api_key ,
22
+ environment : base_url
23
+ )
24
+ end
25
+
14
26
# @return [String] Transcript ID
15
27
def transcript_id
16
28
ENV . fetch ( "TEST_TRANSCRIPT_ID" )
@@ -22,20 +34,17 @@ def transcript_ids
22
34
end
23
35
24
36
def test_upload_file_with_file
25
- client = AssemblyAI ::Client . new ( api_key : api_key )
26
37
file = File . new ( "./test/gore-short.wav" )
27
38
uploaded_file = client . files . upload ( file : file )
28
39
assert !uploaded_file . upload_url . nil?
29
40
end
30
41
31
42
def test_upload_file_with_path
32
- client = AssemblyAI ::Client . new ( api_key : api_key )
33
43
uploaded_file = client . files . upload ( file : "./test/gore-short.wav" )
34
44
assert !uploaded_file . upload_url . nil?
35
45
end
36
46
37
47
def test_upload_file_with_base64_string
38
- client = AssemblyAI ::Client . new ( api_key : api_key )
39
48
uploaded_file = client . files . upload ( file : File . read ( "./test/gore-short.wav" ) )
40
49
assert !uploaded_file . upload_url . nil?
41
50
end
@@ -46,7 +55,6 @@ def test_init
46
55
end
47
56
48
57
def test_pagination
49
- client = AssemblyAI ::Client . new ( api_key : api_key )
50
58
transcript_list = client . transcripts . list
51
59
52
60
count = 0
@@ -69,24 +77,19 @@ def test_pagination
69
77
end
70
78
71
79
def test_transcribe
72
- client = AssemblyAI ::Client . new ( api_key : api_key )
73
80
transcript = client . transcripts . transcribe ( audio_url : "https://storage.googleapis.com/aai-web-samples/espn-bears.m4a" )
74
81
assert transcript . status == AssemblyAI ::Transcripts ::TranscriptStatus ::COMPLETED
75
82
end
76
83
77
84
def test_submit
78
85
# Transcribe
79
- client = AssemblyAI ::Client . new ( api_key : api_key )
80
-
81
86
transcript_submission = client . transcripts . submit ( audio_url : "https://storage.googleapis.com/aai-web-samples/espn-bears.m4a" )
82
87
assert !transcript_submission . id . nil?
83
88
gotten_transcript = client . transcripts . get ( transcript_id : transcript_submission . id )
84
89
assert gotten_transcript . id == transcript_submission . id
85
90
end
86
91
87
92
def test_polling
88
- client = AssemblyAI ::Client . new ( api_key : api_key )
89
-
90
93
transcript = client . transcripts . submit ( audio_url : "https://storage.googleapis.com/aai-web-samples/espn-bears.m4a" )
91
94
assert !transcript . id . nil?
92
95
@@ -95,7 +98,6 @@ def test_polling
95
98
end
96
99
97
100
def test_lemur
98
- client = AssemblyAI ::Client . new ( api_key : api_key )
99
101
assert !client . lemur . summary ( transcript_ids : transcript_ids ) . response . nil?
100
102
101
103
qa_response = client . lemur . question_answer (
0 commit comments