Skip to content

Commit

Permalink
Merge pull request #126 from solaoi/main
Browse files Browse the repository at this point in the history
update to v0.9.9
  • Loading branch information
solaoi authored Apr 7, 2024
2 parents 8002f46 + a68e528 commit 0683637
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ jobs:
releaseDraft: true
prerelease: false
args: --target aarch64-apple-darwin

- name: Contribute List
uses: akhilmhdh/contributors-readme-action@v2.3.6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ unzip ./src-tauri/resources/vosk-model-ja-$VOSK_MODEL_VERSION.zip -d ./src-tauri
rm ./src-tauri/resources/vosk-model-ja-$VOSK_MODEL_VERSION.zip
# whisper
curl -LO https://huggingface.co/datasets/ggerganov/whisper.cpp/resolve/main/ggml-large.bin
mv ggml-large.bin ./src-tauri/resources
curl -LO https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v1.bin
mv ggml-large-v1.bin ./src-tauri/resources/ggml-large.bin
```

### voskのライブラリ更新
Expand Down Expand Up @@ -77,3 +77,8 @@ yarn tauri dev
```
yarn tauri build
```

## Contributors

<!-- readme: contributors -start -->
<!-- readme: contributors -end -->
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lycoris",
"private": true,
"version": "0.9.8",
"version": "0.9.9",
"type": "module",
"license": "MIT",
"engines": {
Expand Down
8 changes: 4 additions & 4 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lycoris"
version = "0.9.8"
version = "0.9.9"
description = "Lycoris is an offline voice memo"
authors = ["solaoi"]
license = "MIT"
Expand Down
1 change: 1 addition & 0 deletions src-tauri/migrations/001.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ INSERT INTO models(model_name, model_type) VALUES("base", "whisper");
INSERT INTO models(model_name, model_type) VALUES("base.en", "whisper");
INSERT INTO models(model_name, model_type) VALUES("large", "whisper");
INSERT INTO models(model_name, model_type) VALUES("large-distil.en", "whisper");
INSERT INTO models(model_name, model_type) VALUES("large-distil.ja", "whisper");
INSERT INTO models(model_name, model_type) VALUES("medium", "whisper");
INSERT INTO models(model_name, model_type) VALUES("medium.en", "whisper");
INSERT INTO models(model_name, model_type) VALUES("small", "whisper");
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/module/model_type_whisper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub enum ModelTypeWhisper {
BaseEn,
Large,
LargeDistilEn,
LargeDistilJa,
Medium,
MediumEn,
Small,
Expand All @@ -20,6 +21,7 @@ impl ModelTypeWhisper {
ModelTypeWhisper::BaseEn => "base.en",
ModelTypeWhisper::Large => "large",
ModelTypeWhisper::LargeDistilEn => "large-distil.en",
ModelTypeWhisper::LargeDistilJa => "large-distil.ja",
ModelTypeWhisper::Medium => "medium",
ModelTypeWhisper::MediumEn => "medium.en",
ModelTypeWhisper::Small => "small",
Expand All @@ -39,6 +41,7 @@ impl FromStr for ModelTypeWhisper {
"base.en" => Ok(ModelTypeWhisper::BaseEn),
"large" => Ok(ModelTypeWhisper::Large),
"large-distil.en" => Ok(ModelTypeWhisper::LargeDistilEn),
"large-distil.ja" => Ok(ModelTypeWhisper::LargeDistilJa),
"medium" => Ok(ModelTypeWhisper::Medium),
"medium.en" => Ok(ModelTypeWhisper::MediumEn),
"small" => Ok(ModelTypeWhisper::Small),
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/src/module/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ impl Record {
.expect("Could not build stream");

stream.play().expect("Could not play stream");

let app_handle = self.app_handle.clone();
app_handle.clone().emit_all("readyToRecognize", "").unwrap();

let (stop_writer_tx, stop_writer_rx) = sync_channel(1);
let is_converting = Arc::new(Mutex::new(false));
let (stop_convert_tx, stop_convert_rx) = unbounded();
Expand Down
3 changes: 3 additions & 0 deletions src-tauri/src/module/record_desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ impl RecordDesktop {
);
stream.start_capture().ok();

let app_handle = self.app_handle.clone();
app_handle.clone().emit_all("readyToRecognize", "").unwrap();

let (stop_writer_tx, stop_writer_rx) = sync_channel(1);
let is_converting = Arc::new(Mutex::new(false));
let (stop_convert_tx, stop_convert_rx) = unbounded();
Expand Down
7 changes: 5 additions & 2 deletions src-tauri/src/module/transcriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ impl Transcriber {
model_type = "small";
} else if transcription_accuracy.starts_with("medium") {
model_type = "medium"
} else if transcription_accuracy.starts_with("large-distil.en"){
} else if transcription_accuracy.starts_with("large-distil.en") {
model_type = "large-distil.en"
} else if transcription_accuracy.starts_with("large-distil.ja") {
model_type = "large-distil.ja"
} else if transcription_accuracy.starts_with("large") {
model_type = "large"
}
Expand All @@ -24,7 +26,8 @@ impl Transcriber {
.to_string_lossy()
.to_string();

return WhisperContext::new_with_params(&model_path, WhisperContextParameters::default()).expect("failed to load whisper model");
return WhisperContext::new_with_params(&model_path, WhisperContextParameters::default())
.expect("failed to load whisper model");
}

pub fn build_params(
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"package": {
"productName": "Lycoris",
"version": "0.9.8"
"version": "0.9.9"
},
"tauri": {
"allowlist": {
Expand Down
10 changes: 10 additions & 0 deletions src/components/molecules/RecordPreparingButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const RecordPreparingButton = (): JSX.Element => {
return (
<button className="btn gap-2 glass text-secondary" disabled>
<div className="radial-progress animate-spin-slow" style={{ "--value": 85, "--size": "1.4rem", "--thickness": "2px" } as React.CSSProperties} />
録音準備中
</button>
)
}

export { RecordPreparingButton }
13 changes: 13 additions & 0 deletions src/components/molecules/TranscriptionAccuracy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ const TranscriptionAccuracy = (): JSX.Element => {
return "文字起こし:高";
case "large-distil.en":
return "文字起こし:英";
case "large-distil.ja":
return "文字起こし:日";
case "online-transcript":
return "文字起こし:オンライン";
case "online-chat":
return "AI:オンライン";
case "small-translate-to-en":
return "翻訳(英):低";
case "medium-translate-to-en":
Expand Down Expand Up @@ -102,6 +108,13 @@ const TranscriptionAccuracy = (): JSX.Element => {
return a
}
}
if (c === "large-distil.ja") {
if (speakerLanguage?.startsWith("ja") || speakerLanguage?.startsWith("small-ja")) {
return [...a, c]
} else {
return a
}
}
return [...a, c, `${c}-translate-to-en`]
}, []).map((model, i) => (
<li key={"transcription-accuracy_" + i}>
Expand Down
17 changes: 16 additions & 1 deletion src/components/organisms/NoteMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { TraceStartButton } from '../molecules/TraceStartButton'
import { TraceStopButton } from '../molecules/TraceStopButton'
import { tracingState } from '../../store/atoms/tracingState'
import { tracingNoteState } from '../../store/atoms/tracingNoteState'
import { RecordPreparingButton } from '../molecules/RecordPreparingButton'

const NoteMain = (): JSX.Element => {
const transcriptionAccuracy = useRecoilValue(transcriptionAccuracyState)
Expand All @@ -42,6 +43,7 @@ const NoteMain = (): JSX.Element => {
setShowGotoBottom(true);
}
}, []);
const [isReadyToRecognize, setIsReadyToRecognize] = useState(false);
useEffect(() => {
const scrollContainer = scrollContainerRef.current;
if (scrollContainer) {
Expand Down Expand Up @@ -121,6 +123,19 @@ const NoteMain = (): JSX.Element => {
}
}, [recordingNote, isTracing])

useEffect(() => {
if (isRecording) {
const unlistenReadyToRecognize = listen('readyToRecognize', () => {
setIsReadyToRecognize(true);
});
return () => {
unlistenReadyToRecognize.then(f => f());
}
} else {
setIsReadyToRecognize(false);
}
}, [isRecording])

return (<>
<div className="max-w-7xl mx-auto py-2 px-4 sm:px-6 lg:px-8 bg-white flex items-center group relative overflow-x-hidden" style={{ height: "64px" }} >
<h1 className="overflow-hidden select-none text-ellipsis whitespace-nowrap text-2xl tracking-tight font-bold text-gray-600 flex-1 cursor-pointer mr-2 hover:border-base-300 border-2 border-transparent rounded-lg"
Expand Down Expand Up @@ -152,7 +167,7 @@ const NoteMain = (): JSX.Element => {
<TraceStartButton />}
</div>
<div className="flex-none">
{(isRecording && recordingNote === selectedNote?.note_id) ? <RecordStopButton /> : <RecordStartButton />}
{(isRecording && recordingNote === selectedNote?.note_id) ? isReadyToRecognize ? <RecordStopButton /> : <RecordPreparingButton /> : <RecordStartButton />}
</div>
<div className={`absolute top-0 -inset-full h-full w-1/2 z-5 block transform -skew-x-12 bg-gradient-to-r from-transparent to-red-100 opacity-40 ${(isRecording && recordingNote === selectedNote?.note_id) && "animate-shine"}`} />
<div className={`absolute top-0 -inset-full h-full w-1/2 z-5 block transform -skew-x-12 bg-gradient-to-r from-transparent to-yellow-100 opacity-40 ${(isTracing && tracingNote === selectedNote?.note_id) && "animate-shine"}`} />
Expand Down
7 changes: 7 additions & 0 deletions src/components/organisms/SettingsMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ const SettingsMain = (): JSX.Element => {
</div>
<ModelDownloadWhisperProgress modelType="large-distil.en" />
</div>
<div style={{ height: "86px" }}>
<div className="flex items-center justify-between mb-2">
<p>言語パック(日本語:速度優先)</p>
<ModelDownloadWhisperButton modelType="large-distil.ja" />
</div>
<ModelDownloadWhisperProgress modelType="large-distil.ja" />
</div>
</div>
</div>
<div className="px-5">
Expand Down

0 comments on commit 0683637

Please sign in to comment.