Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name: app

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: core

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

Expand Down
7 changes: 4 additions & 3 deletions apps/app/lib/app_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ class AppState extends ChangeNotifier {
source: item.path,
copyPath: copyPath,
prepare: lane == Lane.prepare,
aligns: (transcriptionModels.where((m) => m.id == item.settings.transcriptionModel).firstOrNull ??
recommendedTranscription)
.aligner,
aligns:
(transcriptionModels.where((m) => m.id == item.settings.transcriptionModel).firstOrNull ??
recommendedTranscription)
.aligner,
),
);
transcriber.addListener(notifyListeners);
Expand Down
11 changes: 9 additions & 2 deletions apps/app/lib/data/transcript.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ List<PreviewSegment> parsePreview(String json) => [
/// its draft, in the piece's place.
List<PreviewSegment> addPreview(List<PreviewSegment> shown, String json) {
final incoming = parsePreview(json);
final timed = {for (final p in incoming) if (!p.draft) p.chunk};
final all = [for (final p in shown) if (!(p.draft && timed.contains(p.chunk))) p, ...incoming];
final timed = {
for (final p in incoming)
if (!p.draft) p.chunk,
};
final all = [
for (final p in shown)
if (!(p.draft && timed.contains(p.chunk))) p,
...incoming,
];
// By piece, keeping the order within one (List.sort is not stable).
final order = [for (var i = 0; i < all.length; i++) i];
order.sort((a, b) {
Expand Down
2 changes: 1 addition & 1 deletion src/backends/whisper/whisper_transcriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void HandOver(whisper_context* context, Run& run) {
std::vector<Word> words = AssembleWords(tokens, language);
if (words.empty()) continue;
const SampleIndex heard = std::min(ToSamples(words.back().end), run.samples);
run.on_words({.words = std::move(words), .language = language});
run.on_words({.words = std::move(words), .language = language, .text = {}});
if (run.samples > 0) {
run.on_progress(static_cast<double>(heard) / static_cast<double>(run.samples));
}
Expand Down
6 changes: 4 additions & 2 deletions src/capi/checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <exception>
#include <fstream>
#include <iterator>
#include <sstream>
#include <system_error>
#include <utility>

Expand All @@ -29,7 +29,9 @@ std::optional<Checkpoint> CheckpointFile::Load() {
{
std::ifstream in(path_, std::ios::binary);
if (!in) return std::nullopt;
text.assign(std::istreambuf_iterator<char>(in), std::istreambuf_iterator<char>());
std::ostringstream content;
content << in.rdbuf();
text = std::move(content).str();
}
Checkpoint checkpoint;
std::string kept; // the complete lines
Expand Down
4 changes: 2 additions & 2 deletions tests/fakes/fake_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ class FakeTranscriber : public Transcriber {
return a.second < b.second;
})->first;
}
TranscribedWords piece{.words = {}, .language = language};
TranscribedWords piece{.words = {}, .language = language, .text = {}};
const auto hand_over = [&] {
const SampleIndex heard = ToSamples(piece.words.back().end);
on_words(std::move(piece));
piece = {.words = {}, .language = language};
piece = {.words = {}, .language = language, .text = {}};
on_progress(std::min(1.0, static_cast<double>(heard) / static_cast<double>(request.pcm.size())));
};
for (std::size_t i = 0; i < bursts.size(); ++i) {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/audio_input_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ TEST(LoudnessTest, AShortLoudSoundDoesNotHoldTheGainDownAroundIt) {
for (std::size_t i = 16000 * 20; i < 16000 * 20 + 160; ++i) pcm[i] = (i / 8) % 2 ? 1.0f : -1.0f;
const auto out = EvenOut(pcm);
ASSERT_EQ(out.size(), pcm.size());
const auto gain = [&](int from, int to) {
const auto gain = [&](std::size_t from, std::size_t to) {
const std::span<const float> before(pcm.data() + 16000 * from, 16000 * (to - from));
const std::span<const float> after(out.data() + 16000 * from, 16000 * (to - from));
return Rms(after) / Rms(before);
Expand Down
Loading