runapi-fish-audio 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 370d607320f1810125fdf732de7b8ec975b26ca62c47b1886338601ebdec10db
4
- data.tar.gz: 86236d72fc06d5e105701df377d11542d5b291828c4cad809017505d1a85c58f
3
+ metadata.gz: 7787228caf6e8b7f36cde94f0930290801d93ae6fb7d613a948ca44013d3959e
4
+ data.tar.gz: '087c22f1cb69cdf5223f51b6448a966747e98352cecd52207bc00f04dda9ac82'
5
5
  SHA512:
6
- metadata.gz: 57c267f3e0e8cf89caef1f2d7032363b79a8e7ae3809350887936a2e0d29912f56e8e3e2bea6fd1c0fc04076ab21cf084dd7f7c17a681fadda68cf8f243777b8
7
- data.tar.gz: 100dfc8467279f6b2901f44269962fdb3d4ca630aa83cf5a50bcdc632fdd0572257aabe4ea7728730156fa7f6d8fa9e6a4e86d0acf31f9c7faa97b5ef024d19a
6
+ metadata.gz: 75e4e995715cca713106a0924f13589d64abe674cc490789bef0b2759563a22f1fa706ceb314302e04fcf811d7fd71659639c5917a3071ecb37555410442cda5
7
+ data.tar.gz: 7ca414ef2c860949a2de6fcfd981e6b0e6f93b306025b0f90a392394a3c47e55b1c409ba1d8753ab98b5bb9e49cd9863533588a367c2a4e54e84555ab2d63015
data/README.md CHANGED
@@ -1,9 +1,18 @@
1
1
  # Fish Audio Ruby SDK for RunAPI
2
2
 
3
- Install `runapi-fish-audio`, create `RunApi::FishAudio::Client`, and call `client.text_to_speech.run(model: "s2.1-pro", text: "Hello [excited]", output_format: "wav", sample_rate_hz: 44_100)`.
3
+ Install `runapi-fish-audio` and create a `RunApi::FishAudio::Client`.
4
+
5
+ ```ruby
6
+ created = client.create_voice.run(name: "Narrator", source_audio_url: "https://cdn.runapi.ai/public/samples/voice.mp3")
7
+ voice = client.get_voice.run(voice_id: created.voice.voice_id)
8
+ raise "Voice is #{voice.voice.state}" unless voice.voice.state == "trained"
9
+ result = client.text_to_speech.run(model: "s2.1-pro", text: "Hello [excited]", voice_id: created.voice.voice_id, output_format: "wav", sample_rate_hz: 44_100)
10
+ ```
4
11
 
5
12
  Pass optional `references` entries with base64-encoded raw audio bytes and exact transcripts for request-scoped voice matching.
6
13
 
14
+ Use `list_voices` and `get_voice` to inspect account-owned voice resources. Only `trained` voices can be submitted for speech generation; a returned `voice_id` is a best-effort reference and may stop working later. Update, delete, revoke, or voice-library management methods are not provided; voice retention is not promised.
15
+
7
16
  The output defaults to MP3. Select WAV with `output_format`; `bitrate_kbps` applies only to MP3.
8
17
 
9
18
  Model details and pricing: https://runapi.ai/models/fish-audio/s2.1-pro
@@ -2,13 +2,16 @@
2
2
 
3
3
  module RunApi
4
4
  module FishAudio
5
- # Fish Audio speech generation client.
5
+ # Fish Audio reusable voice and speech generation client.
6
6
  class Client < RunApi::Core::Client
7
- attr_reader :text_to_speech
7
+ attr_reader :text_to_speech, :create_voice, :list_voices, :get_voice
8
8
 
9
9
  def initialize(api_key: nil, **options)
10
10
  super
11
11
  @text_to_speech = Resources::TextToSpeech.new(http)
12
+ @create_voice = Resources::CreateVoice.new(http)
13
+ @list_voices = Resources::ListVoices.new(http)
14
+ @get_voice = Resources::GetVoice.new(http)
12
15
  end
13
16
  end
14
17
  end
@@ -3,6 +3,45 @@
3
3
  module RunApi
4
4
  module FishAudio
5
5
  CONTRACT = {
6
+ "create-voice" => {
7
+ "models" => [],
8
+ "fields_by_model" => {
9
+ "_" => {
10
+ "name" => {
11
+ "required" => true
12
+ },
13
+ "source_audio_url" => {
14
+ "required" => true
15
+ }
16
+ }
17
+ }
18
+ },
19
+ "get-voice" => {
20
+ "models" => [],
21
+ "fields_by_model" => {
22
+ "_" => {
23
+ "voice_id" => {
24
+ "required" => true
25
+ }
26
+ }
27
+ }
28
+ },
29
+ "list-voices" => {
30
+ "models" => [],
31
+ "fields_by_model" => {
32
+ "_" => {
33
+ "page_number" => {
34
+ "min" => 1,
35
+ "type" => "integer"
36
+ },
37
+ "page_size" => {
38
+ "min" => 1,
39
+ "max" => 100,
40
+ "type" => "integer"
41
+ }
42
+ }
43
+ }
44
+ },
6
45
  "text-to-speech" => {
7
46
  "models" => ["s1", "s2-pro", "s2.1-pro"],
8
47
  "fields_by_model" => {
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module FishAudio
5
+ module Resources
6
+ # Creates an account-owned reusable voice from source audio.
7
+ class CreateVoice
8
+ include RunApi::Core::ResourceHelpers
9
+
10
+ ENDPOINT = "/api/v1/fish_audio/voices"
11
+ RESPONSE_CLASS = Types::VoiceResponse
12
+
13
+ def initialize(http)
14
+ @http = http
15
+ end
16
+
17
+ def run(options: nil, **params)
18
+ params = compact_params(params)
19
+ validate_contract!(CONTRACT["create-voice"], params)
20
+ request(:post, ENDPOINT, body: params, options: options)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module FishAudio
5
+ module Resources
6
+ # Gets one reusable voice owned by the current account.
7
+ class GetVoice
8
+ include RunApi::Core::ResourceHelpers
9
+
10
+ ENDPOINT = "/api/v1/fish_audio/voices"
11
+ RESPONSE_CLASS = Types::VoiceResponse
12
+
13
+ def initialize(http)
14
+ @http = http
15
+ end
16
+
17
+ def run(voice_id:, options: nil)
18
+ params = compact_params(voice_id: voice_id)
19
+ validate_contract!(CONTRACT["get-voice"], params)
20
+ path = "#{ENDPOINT}/#{URI.encode_uri_component(voice_id)}"
21
+ request(:get, path, options: options)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module FishAudio
5
+ module Resources
6
+ # Lists reusable voices owned by the current account.
7
+ class ListVoices
8
+ include RunApi::Core::ResourceHelpers
9
+
10
+ ENDPOINT = "/api/v1/fish_audio/voices"
11
+ RESPONSE_CLASS = Types::VoicesResponse
12
+
13
+ def initialize(http)
14
+ @http = http
15
+ end
16
+
17
+ def run(options: nil, **params)
18
+ params = compact_params(params)
19
+ validate_contract!(CONTRACT["list-voices"], params)
20
+ query = URI.encode_www_form(params)
21
+ path = query.empty? ? ENDPOINT : "#{ENDPOINT}?#{query}"
22
+ request(:get, path, options: options)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,6 +3,28 @@
3
3
  module RunApi
4
4
  module FishAudio
5
5
  module Types
6
+ # An account-owned reusable voice.
7
+ class Voice < RunApi::Core::BaseModel
8
+ required :voice_id, String
9
+ optional :name, String
10
+ required :state, String
11
+ end
12
+
13
+ # Response containing one reusable voice.
14
+ class VoiceResponse < RunApi::Core::BaseModel
15
+ required :voice, -> { Voice }
16
+ required :billing, RunApi::Core::TaskBillingFacts
17
+ end
18
+
19
+ # Paginated response containing account-owned reusable voices.
20
+ class VoicesResponse < RunApi::Core::BaseModel
21
+ required :voices, [-> { Voice }]
22
+ required :total, Integer
23
+ required :page_number, Integer
24
+ required :page_size, Integer
25
+ required :billing, RunApi::Core::TaskBillingFacts
26
+ end
27
+
6
28
  # A RunAPI-managed audio result.
7
29
  class Audio < RunApi::Core::BaseModel
8
30
  required :url, String
@@ -3,6 +3,9 @@
3
3
  require "runapi/core"
4
4
  require_relative "fish_audio/types"
5
5
  require_relative "fish_audio/contract_gen"
6
+ require_relative "fish_audio/resources/create_voice"
7
+ require_relative "fish_audio/resources/list_voices"
8
+ require_relative "fish_audio/resources/get_voice"
6
9
  require_relative "fish_audio/resources/text_to_speech"
7
10
  require_relative "fish_audio/client"
8
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-fish-audio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,17 +15,15 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.3.3
18
+ version: 0.4.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.3.3
26
- description: 'Install `runapi-fish-audio`, create `RunApi::FishAudio::Client`, and
27
- call `client.text_to_speech.run(model: "s2.1-pro", text: "Hello [excited]", output_format:
28
- "wav", sample_rate_hz: 44_100)`.'
25
+ version: 0.4.0
26
+ description: Install `runapi-fish-audio` and create a `RunApi::FishAudio::Client`.
29
27
  email:
30
28
  - contact@runapi.ai
31
29
  executables: []
@@ -39,6 +37,9 @@ files:
39
37
  - lib/runapi/fish_audio.rb
40
38
  - lib/runapi/fish_audio/client.rb
41
39
  - lib/runapi/fish_audio/contract_gen.rb
40
+ - lib/runapi/fish_audio/resources/create_voice.rb
41
+ - lib/runapi/fish_audio/resources/get_voice.rb
42
+ - lib/runapi/fish_audio/resources/list_voices.rb
42
43
  - lib/runapi/fish_audio/resources/text_to_speech.rb
43
44
  - lib/runapi/fish_audio/types.rb
44
45
  homepage: https://runapi.ai/models/fish-audio
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
68
  requirements: []
68
- rubygems_version: 4.0.17
69
+ rubygems_version: 4.0.10
69
70
  specification_version: 4
70
71
  summary: Fish Audio Ruby SDK for RunAPI
71
72
  test_files: []