Skip to content

Commit 606889e

Browse files
authored
Add voice gender to Audio translation
1 parent c685ea3 commit 606889e

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

lib/lara/audio.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def initialize(client, s3_client = S3Client.new)
2525
# Uploads an audio file to S3 and creates a translation job.
2626
# @return [Lara::Models::Audio]
2727
def upload(file_path:, filename:, target:, source: nil, adapt_to: nil, glossaries: nil,
28-
no_trace: false, style: nil)
28+
no_trace: false, style: nil, voice_gender: nil)
2929
response_data = @client.get("/v2/audio/upload-url", params: { filename: filename })
3030
url = response_data["url"]
3131
fields = response_data["fields"]
@@ -38,7 +38,8 @@ def upload(file_path:, filename:, target:, source: nil, adapt_to: nil, glossarie
3838
source: source,
3939
adapt_to: adapt_to,
4040
glossaries: glossaries,
41-
style: style
41+
style: style,
42+
voice_gender: voice_gender
4243
}.compact
4344

4445
headers = {}
@@ -67,9 +68,10 @@ def download(id)
6768
# Translates an audio file end-to-end
6869
# @return [String] translated audio bytes
6970
def translate(file_path:, filename:, target:, source: nil, adapt_to: nil, glossaries: nil,
70-
no_trace: false, style: nil)
71+
no_trace: false, style: nil, voice_gender: nil)
7172
audio = upload(file_path: file_path, filename: filename, target: target, source: source,
72-
adapt_to: adapt_to, glossaries: glossaries, no_trace: no_trace, style: style)
73+
adapt_to: adapt_to, glossaries: glossaries, no_trace: no_trace, style: style,
74+
voice_gender: voice_gender)
7375

7476
max_wait_time = 60 * 15 # 15 minutes
7577
start = Time.now

lib/lara/models/audio.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
module Lara
66
module Models
7+
module VoiceGender
8+
MALE = "male"
9+
FEMALE = "female"
10+
ALL = [MALE, FEMALE].freeze
11+
12+
def self.valid?(value)
13+
ALL.include?(value)
14+
end
15+
end
16+
717
module AudioStatus
818
INITIALIZED = "initialized"
919
ANALYZING = "analyzing"

0 commit comments

Comments
 (0)