Skip to content

Commit

Permalink
ハイブリッド音声認識をリファクタ
Browse files Browse the repository at this point in the history
  • Loading branch information
solaoi committed Jan 2, 2025
1 parent dbdbcce commit 10a503f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/module/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl Action {
});

let post_body = json!({
"model": "gpt-4o-2024-08-06",
"model": "gpt-4o",
"temperature": temperature,
"messages": messages,
"response_format": response_format
Expand Down
15 changes: 11 additions & 4 deletions src-tauri/src/module/transcription_hybrid_online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl TranscriptionHybridOnline {
headers.insert(CONTENT_TYPE, HeaderValue::from_static("application/json"));

let mut messages: Vec<Value> = Vec::new();
let system_prompt = "あなたの役割は、ReazonSpeechとWhisperの出力を統合して「正確で読みやすい文字起こし」を作成することです。
let system_prompt = String::from("あなたの役割は、ReazonSpeechとWhisperの出力を統合して「正確で読みやすい文字起こし」を作成することです。
### 目的
- **正確性の確保**:発話内容を正確に伝えます。
Expand All @@ -125,12 +125,18 @@ impl TranscriptionHybridOnline {
- **文脈と推測の活用**:文脈から適切な言葉を推測し、誤認識を修正してください。
- **用語の一貫性**:同じ用語や表現は一貫して使用してください。
- **自然な日本語表現**:文法的に正しく、自然な日本語になるように修正してください。
- **途中で途切れた部分の明示**:発話の途中で始まったり、途中で終わっている場合は、「...」を挿入して途切れていることを明示してください。
") +
if !latest_speeches.is_empty() {"- **会話履歴の活用**:`history`(timestampとcontent)を必要に応じて参照し、誤認識の修正や表現の調整を行ってください。"}
else {""} + "
### 統合手順
1. **テキストの確定**
- ReazonSpeechの出力をベースに発話内容を確定します。
- 必要に応じてWhisperの出力や文脈を参考に、内容を補完します。
" +
if !latest_speeches.is_empty() {" - 必要に応じてWhisperの出力や文脈(`history`)を参考に、内容を補完します。"}
else {" - 必要に応じてWhisperの出力を参考に、内容を補完します。"} + "
2. **誤認識の修正**
- 文脈や一般知識を活用し、誤った表現を正しく修正します。特に専門用語や固有名詞に注意してください。
Expand All @@ -140,6 +146,7 @@ impl TranscriptionHybridOnline {
4. **表現の調整**
- 冗長な表現を避け、自然で簡潔な文章に整えます。
- 途中から始まっている発話や、途中で終わっている発話があれば「...」を挿入して、発言の断片を示します。
5. **最終チェック**
- 全体を見直し、一貫性と正確さ、自然な流れを確認します。
Expand All @@ -150,7 +157,7 @@ impl TranscriptionHybridOnline {
{
\"integrated_transcription\": \"統合された文字起こし結果をここに挿入\"
}
```".to_string();
```";

messages.push(json!({
"role": "system",
Expand Down Expand Up @@ -186,7 +193,7 @@ impl TranscriptionHybridOnline {
});

let post_body = json!({
"model": "gpt-4o-2024-08-06",
"model": "gpt-4o",
"temperature": temperature,
"messages": messages,
"response_format": response_format
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/NoteMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ const NoteMain = (): JSX.Element => {
</button>
<div className="w-20 invisible rounded text-[12px]
font-bold text-white py-1 bg-slate-600 top-[154px] right-4
group-hover:visible absolute text-center">ダウンロード
group-hover:visible absolute text-center z-10">ダウンロード
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ body {
.znc pre {
width: 100%;
margin: 1.5rem 0!important;
background-color: #bfbfbf;
}

.znc pre:has(.lang-mermaid) {
Expand Down

0 comments on commit 10a503f

Please sign in to comment.