Skip to content

Commit 510ef4c

Browse files
committed
Update README
1 parent 3e0b52a commit 510ef4c

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

bindings/ruby/README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ def format_time(time_ms)
114114
"%02d:%02d:%02d.%03d" % [hour, min, sec, decimal_part]
115115
end
116116

117-
whisper.transcribe("path/to/audio.wav", params)
118-
119-
whisper.each_segment.with_index do |segment, index|
120-
line = "[%{nth}: %{st} --> %{ed}] %{text}" % {
121-
nth: index + 1,
122-
st: format_time(segment.start_time),
123-
ed: format_time(segment.end_time),
124-
text: segment.text
125-
}
126-
line << " (speaker turned)" if segment.speaker_next_turn?
127-
puts line
128-
end
117+
whisper
118+
.transcribe("path/to/audio.wav", params)
119+
.each_segment.with_index do |segment, index|
120+
line = "[%{nth}: %{st} --> %{ed}] %{text}" % {
121+
nth: index + 1,
122+
st: format_time(segment.start_time),
123+
ed: format_time(segment.end_time),
124+
text: segment.text
125+
}
126+
line << " (speaker turned)" if segment.speaker_next_turn?
127+
puts line
128+
end
129129

130130
```
131131

@@ -216,10 +216,11 @@ reader = WaveFile::Reader.new("path/to/audio.wav", WaveFile::Format.new(:mono, :
216216
samples = reader.enum_for(:each_buffer).map(&:samples).flatten
217217

218218
whisper = Whisper::Context.new("base")
219-
whisper.full(Whisper::Params.new, samples)
220-
whisper.each_segment do |segment|
221-
puts segment.text
222-
end
219+
whisper
220+
.full(Whisper::Params.new, samples)
221+
.each_segment do |segment|
222+
puts segment.text
223+
end
223224
```
224225

225226
The second argument `samples` may be an array, an object with `length` and `each` method, or a MemoryView. If you can prepare audio data as C array and export it as a MemoryView, whispercpp accepts and works with it with zero copy.

0 commit comments

Comments
 (0)