cohere-transcribe 0.1.2 → 0.1.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +9 -7
  4. data/ext/cohere_transcribe_native/.gitignore +6 -0
  5. data/ext/cohere_transcribe_native/CMakeLists.txt +8 -0
  6. data/ext/cohere_transcribe_native/audio_abi.cpp +20 -0
  7. data/ext/cohere_transcribe_native/audio_exports.macos +1 -0
  8. data/ext/cohere_transcribe_native/audio_exports.map +1 -0
  9. data/ext/cohere_transcribe_native/test/abi_smoke.rb +26 -0
  10. data/lib/cohere/transcribe/alignment/aligner.rb +40 -7
  11. data/lib/cohere/transcribe/asr/native.rb +43 -97
  12. data/lib/cohere/transcribe/audio/decoder.rb +184 -75
  13. data/lib/cohere/transcribe/audio/ffmpeg_native.rb +84 -32
  14. data/lib/cohere/transcribe/audio/segmentation.rb +1 -0
  15. data/lib/cohere/transcribe/cli.rb +30 -22
  16. data/lib/cohere/transcribe/configuration.rb +13 -0
  17. data/lib/cohere/transcribe/constants.rb +1 -1
  18. data/lib/cohere/transcribe/doctor.rb +2 -1
  19. data/lib/cohere/transcribe/hub.rb +446 -58
  20. data/lib/cohere/transcribe/input.rb +18 -3
  21. data/lib/cohere/transcribe/internal/interruptible_native_call.rb +70 -0
  22. data/lib/cohere/transcribe/internal/session_ownership.rb +61 -0
  23. data/lib/cohere/transcribe/internal/utf8.rb +19 -0
  24. data/lib/cohere/transcribe/model_identity.rb +10 -1
  25. data/lib/cohere/transcribe/output/publication.rb +95 -86
  26. data/lib/cohere/transcribe/pytorch_checkpoint.rb +38 -22
  27. data/lib/cohere/transcribe/runtime/engine.rb +37 -16
  28. data/lib/cohere/transcribe/runtime/preparation.rb +212 -35
  29. data/lib/cohere/transcribe/runtime/resources.rb +28 -62
  30. data/lib/cohere/transcribe/state/checkpoint.rb +3 -2
  31. data/lib/cohere/transcribe/state/io.rb +217 -117
  32. data/lib/cohere/transcribe/state/locking.rb +383 -64
  33. data/lib/cohere/transcribe/state/manifest.rb +21 -22
  34. data/lib/cohere/transcribe/types.rb +25 -11
  35. data/lib/cohere/transcribe/version.rb +1 -1
  36. data/sig/cohere/transcribe.rbs +1 -0
  37. metadata +5 -1
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "constants"
4
+ require_relative "internal/utf8"
5
+
3
6
  module Cohere
4
7
  module Transcribe
5
8
  module TypesSupport
6
- DEFAULT_ASR_MODEL_ID = "CohereLabs/cohere-transcribe-arabic-07-2026"
7
- OUTPUT_FORMATS = %w[txt srt vtt json].freeze
9
+ DEFAULT_ASR_MODEL_ID = Cohere::Transcribe::DEFAULT_ASR_MODEL_ID
10
+ OUTPUT_FORMATS = Cohere::Transcribe::OUTPUT_FORMATS
8
11
  EXISTING_POLICIES = %w[error overwrite skip].freeze
9
12
 
10
13
  module KeywordOnlyConstructor
@@ -47,10 +50,21 @@ module Cohere
47
50
  immutable(array)
48
51
  end
49
52
 
50
- def path(value)
53
+ def reference(value)
54
+ source = value.respond_to?(:to_path) ? value.to_path : value
55
+ return immutable(value) unless source.is_a?(String)
56
+
57
+ text = Internal::UTF8.normalize(source)
58
+ text ? text.freeze : immutable(source)
59
+ end
60
+
61
+ def path(value, field: "path")
51
62
  source = value.respond_to?(:to_path) ? value.to_path : value
52
- pathname = Pathname.new(source)
53
- text = pathname.to_s
63
+ raise TypeError, "#{field} must resolve to a text path" unless source.is_a?(String)
64
+
65
+ text = Internal::UTF8.normalize(source)
66
+ raise ArgumentError, "#{field} must contain valid UTF-8" unless text
67
+
54
68
  absolute = text.start_with?("/")
55
69
  prefix = if text.start_with?("//") && !text.start_with?("///")
56
70
  "//"
@@ -84,9 +98,9 @@ module Cohere
84
98
 
85
99
  super(
86
100
  formats: formats,
87
- output_dir: output_dir.nil? ? nil : TypesSupport.path(output_dir),
101
+ output_dir: output_dir.nil? ? nil : TypesSupport.path(output_dir, field: "output_dir"),
88
102
  existing: TypesSupport.immutable(existing),
89
- profile_json: profile_json.nil? ? nil : TypesSupport.path(profile_json)
103
+ profile_json: profile_json.nil? ? nil : TypesSupport.path(profile_json, field: "profile_json")
90
104
  )
91
105
  end
92
106
  end
@@ -183,10 +197,10 @@ module Cohere
183
197
  publication: nil
184
198
  )
185
199
  super(
186
- model: TypesSupport.immutable(model),
187
- model_revision: TypesSupport.immutable(model_revision),
188
- adapter: TypesSupport.immutable(adapter),
189
- adapter_revision: TypesSupport.immutable(adapter_revision),
200
+ model: TypesSupport.reference(model),
201
+ model_revision: TypesSupport.reference(model_revision),
202
+ adapter: TypesSupport.reference(adapter),
203
+ adapter_revision: TypesSupport.reference(adapter_revision),
190
204
  language: TypesSupport.immutable(language),
191
205
  text_only: text_only,
192
206
  recursive: recursive,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cohere
4
4
  module Transcribe
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
@@ -5,6 +5,7 @@ module Cohere
5
5
  DEFAULT_ASR_MODEL_ID: String
6
6
  DEFAULT_ASR_MODEL_REVISION: String
7
7
  SAMPLE_RATE: Integer
8
+ OUTPUT_FORMATS: Array[output_format]
8
9
 
9
10
  type path_input = String | _ToPath
10
11
  type audio_input = path_input | Array[path_input]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cohere-transcribe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Hamdi Ali Fadel
@@ -88,6 +88,7 @@ files:
88
88
  - THIRD_PARTY_NOTICES.md
89
89
  - exe/cohere-transcribe
90
90
  - exe/cohere-transcribe-doctor
91
+ - ext/cohere_transcribe_native/.gitignore
91
92
  - ext/cohere_transcribe_native/CMakeLists.txt
92
93
  - ext/cohere_transcribe_native/README.md
93
94
  - ext/cohere_transcribe_native/audio_abi.cpp
@@ -130,6 +131,9 @@ files:
130
131
  - lib/cohere/transcribe/gguf_writer.rb
131
132
  - lib/cohere/transcribe/hub.rb
132
133
  - lib/cohere/transcribe/input.rb
134
+ - lib/cohere/transcribe/internal/interruptible_native_call.rb
135
+ - lib/cohere/transcribe/internal/session_ownership.rb
136
+ - lib/cohere/transcribe/internal/utf8.rb
133
137
  - lib/cohere/transcribe/licenses/crispasr.txt
134
138
  - lib/cohere/transcribe/loader.rb
135
139
  - lib/cohere/transcribe/model_identity.rb