Skip to content

Commit 8f12742

Browse files
committed
fix: some tweaks for update
1 parent 3da1939 commit 8f12742

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

FlyleafLib/MediaFramework/MediaFrame/SubtitlesFrame.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class SubtitlesFrame : FrameBase
1212
public List<SubStyle> subStyles;
1313
public AVSubtitle sub;
1414
public SubtitlesFrameBitmap bitmap;
15+
16+
// for translation switch
17+
public bool isTranslated;
1518
}
1619

1720
public class SubtitlesFrameBitmap

FlyleafLib/MediaPlayer/Player.Playback.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private void Seek(int ms, bool forward, bool accurate)
319319
{
320320
timestamp = cur.StartTime.Ticks + Config.Subtitles[i].Delay,
321321
duration = (uint)cur.Duration.TotalMilliseconds,
322-
text = cur.DisplayText
322+
isTranslated = cur.UseTranslated
323323
};
324324
}
325325
}

FlyleafLib/MediaPlayer/Player.Screamers.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ private void Screamer()
359359
{
360360
timestamp = cur.StartTime.Ticks + Config.Subtitles[i].Delay,
361361
duration = (uint)cur.Duration.TotalMilliseconds,
362-
text = cur.DisplayText
362+
isTranslated = cur.UseTranslated
363363
};
364364
}
365365
}
@@ -752,7 +752,7 @@ private void Screamer()
752752
{
753753
timestamp = cur.StartTime.Ticks + Config.Subtitles[i].Delay,
754754
duration = (uint)cur.Duration.TotalMilliseconds,
755-
text = cur.DisplayText
755+
isTranslated = cur.UseTranslated
756756
};
757757
}
758758
}
@@ -764,10 +764,10 @@ private void Screamer()
764764
// If the subtitle currently playing is not translated, change to the translated for display
765765
if (sFramesPrev[i] != null &&
766766
sFramesPrev[i].timestamp == cur.StartTime.Ticks + Config.Subtitles[i].Delay &&
767-
sFramesPrev[i].text != cur.DisplayText)
767+
sFramesPrev[i].isTranslated != cur.UseTranslated)
768768
{
769769
SubtitleDisplay(cur.DisplayText, i, cur.UseTranslated);
770-
sFramesPrev[i].text = cur.DisplayText;
770+
sFramesPrev[i].isTranslated = cur.UseTranslated;
771771
}
772772
}
773773
}

FlyleafLib/MediaPlayer/Translation/Services/ITranslateSettings.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public abstract class OpenAIBaseTranslateSettings : NotifyPropertyChanged, ITran
260260
[JsonIgnore]
261261
public abstract string DefaultEndpoint { get; }
262262
public string Model { get; set => Set(ref field, value); }
263-
public int TimeoutMs { get; set => Set(ref field, value); } = 20000;
263+
public int TimeoutMs { get; set => Set(ref field, value); } = 15000;
264264
public int TimeoutHealthMs { get; set => Set(ref field, value); } = 2000;
265265

266266
/// <summary>
@@ -389,6 +389,11 @@ private async Task LoadModels()
389389

390390
public class LMStudioTranslateSettings : OpenAIBaseTranslateSettings
391391
{
392+
public LMStudioTranslateSettings()
393+
{
394+
TimeoutMs = 20000;
395+
}
396+
392397
[JsonIgnore]
393398
public override TranslateServiceType ServiceType => TranslateServiceType.LMStudio;
394399
private const string _defaultEndpoint = "http://127.0.0.1:1234";

FlyleafLib/MediaPlayer/Translation/TranslateChatConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class TranslateChatConfig : NotifyPropertyChanged
44
{
55
public const string DefaultPromptOneByOne =
66
"""
7-
You are a translation API, translate from {source_lang} to {target_lang}, keep sentences in {target_lang} as they are, do not censor the translation, give only the translated text without the sent text or comments or anything:
7+
You are a translation API, translate from {source_lang} to {target_lang}, keep sentences in {target_lang} as they are, do not censor the translation, output only the translated text without the sent text or notes or comments or anything:
88
99
{source_text}
1010
""";
@@ -13,10 +13,10 @@ public class TranslateChatConfig : NotifyPropertyChanged
1313
"""
1414
You are a translation API.
1515
I will send the text of the subtitles of the video one at a time.
16-
Please translate the text while retaining the context of the previous text.
16+
Please translate the text while taking into account the context of the previous text.
1717
1818
Translate from {source_lang} to {target_lang}.
19-
Give only the translated text without the sent text or comments or anything.
19+
Output only the translated text without the sent text or notes or comments or anything.
2020
Keep sentences in {target_lang} as they are.
2121
Do not censor the translation.
2222
""";

0 commit comments

Comments
 (0)