diff --git a/scenarios/cpp/windows/captioning/captioning/captioning.cpp b/scenarios/cpp/windows/captioning/captioning/captioning.cpp index 42930fba9..16227379c 100644 --- a/scenarios/cpp/windows/captioning/captioning/captioning.cpp +++ b/scenarios/cpp/windows/captioning/captioning/captioning.cpp @@ -56,7 +56,7 @@ class Captioning std::shared_ptr m_format = NULL; std::shared_ptr m_callback = NULL; std::shared_ptr m_stream = NULL; - int m_srtSequenceNumber = 0; + int m_srtSequenceNumber = 1; std::optional m_previousCaption = std::nullopt; std::optional m_previousEndTime = std::nullopt; bool m_previousResultIsRecognized = false; @@ -93,7 +93,7 @@ class Captioning std::string retval; if (m_userConfig->useSubRipTextCaptionFormat) { - retval += caption.sequence + "\n"; + retval += std::to_string(caption.sequence) + "\n"; } retval += GetTimestamp(caption.begin, caption.end) + "\n"; retval += caption.text + "\n\n"; @@ -454,10 +454,10 @@ int main(int argc, char* argv[]) " Minimum is 20. Default is 37 (30 for Chinese).\n" " --lines LINES Set the number of lines for a caption to LINES.\n" " Minimum is 1. Default is 2.\n" -" --delay SECONDS How many SECONDS to delay the appearance of each caption.\n" -" Minimum is 0.0. Default is 1.0.\n" -" --remainTime SECONDS How many SECONDS a caption should remain on screen if it is not replaced by another.\n" -" Minimum is 0.0. Default is 1.0.\n\n" +" --delay MILLISECONDS How many MILLISECONDS to delay the appearance of each caption.\n" +" Minimum is 0. Default is 1000.\n" +" --remainTime MILLISECONDS How many MILLISECONDS a caption should remain on screen if it is not replaced by another.\n" +" Minimum is 0. Default is 1000.\n\n" " --quiet Suppress console output, except errors.\n" " --profanity OPTION Valid values: raw, remove, mask\n" " --threshold NUMBER Set stable partial result threshold.\n" diff --git a/scenarios/cpp/windows/captioning/captioning/captioning.vcxproj b/scenarios/cpp/windows/captioning/captioning/captioning.vcxproj index 4bd474d99..836946f8a 100644 --- a/scenarios/cpp/windows/captioning/captioning/captioning.vcxproj +++ b/scenarios/cpp/windows/captioning/captioning/captioning.vcxproj @@ -151,7 +151,11 @@ - + + + + + diff --git a/scenarios/csharp/dotnetcore/captioning/captioning/Program.cs b/scenarios/csharp/dotnetcore/captioning/captioning/Program.cs index 7d0502984..30b554e63 100644 --- a/scenarios/csharp/dotnetcore/captioning/captioning/Program.cs +++ b/scenarios/csharp/dotnetcore/captioning/captioning/Program.cs @@ -26,7 +26,7 @@ namespace Captioning class Program { private UserConfig? _userConfig; - private int _srtSequenceNumber = 0; + private int _srtSequenceNumber = 1; private Caption? _previousCaption; private TimeSpan? _previousEndTime; private bool _previousResultIsRecognized = false; @@ -434,10 +434,10 @@ Default output mode is offline. Minimum is 20. Default is 37 (30 for Chinese). --lines LINES Set the number of lines for a caption to LINES. Minimum is 1. Default is 2. - --delay SECONDS How many SECONDS to delay the appearance of each caption. - Minimum is 0.0. Default is 1.0. - --remainTime SECONDS How many SECONDS a caption should remain on screen if it is not replaced by another. - Minimum is 0.0. Default is 1.0. + --delay MILLISECONDS How many MILLISECONDS to delay the appearance of each caption. + Minimum is 0. Default is 1000. + --remainTime MILLISECONDS How many MILLISECONDS a caption should remain on screen if it is not replaced by another. + Minimum is 0. Default is 1000. --quiet Suppress console output, except errors. --profanity OPTION Valid values: raw, remove, mask Default is mask. diff --git a/scenarios/csharp/dotnetcore/captioning/captioning/UserConfig.cs b/scenarios/csharp/dotnetcore/captioning/captioning/UserConfig.cs index 8d327ccc5..58d4cdbfb 100644 --- a/scenarios/csharp/dotnetcore/captioning/captioning/UserConfig.cs +++ b/scenarios/csharp/dotnetcore/captioning/captioning/UserConfig.cs @@ -45,9 +45,9 @@ public class UserConfig readonly public bool suppressConsoleOutput = false; /// The captioning mode. Default is offline. readonly public CaptioningMode captioningMode = CaptioningMode.Offline; - /// How long (in seconds) a caption should remain on screen. Default is 1.0. + /// How long (in milliseconds) a caption should remain on screen. Default is 1000. readonly public TimeSpan remainTime; - /// How long (in seconds) to delay all caption timestamps. Default is 1.0. + /// How long (in milliseconds) to delay all caption timestamps. Default is 1000. readonly public TimeSpan delay; /// Output captions in SubRip Text format (default is WebVTT format). readonly public bool useSubRipTextCaptionFormat = false; @@ -203,27 +203,27 @@ public static UserConfig UserConfigFromArgs(string[] args, string usage) CaptioningMode captioningMode = CmdOptionExists(args, "--realTime") && !CmdOptionExists(args, "--offline") ? CaptioningMode.RealTime : CaptioningMode.Offline; string? strRemainTime = GetCmdOption(args, "--remainTime"); - TimeSpan timeSpanRemainTime = TimeSpan.FromSeconds(1.0); + TimeSpan timeSpanRemainTime = TimeSpan.FromMilliseconds(1000); if (null != strRemainTime) { - double dblRemainTime = Double.Parse(strRemainTime); - if (dblRemainTime < 0.0) + int intRemainTime = Int32.Parse(strRemainTime); + if (intRemainTime < 0) { - dblRemainTime = 1.0; + intRemainTime = 1000; } - timeSpanRemainTime = TimeSpan.FromSeconds(dblRemainTime); + timeSpanRemainTime = TimeSpan.FromMilliseconds(intRemainTime); } string? strDelay = GetCmdOption(args, "--delay"); - TimeSpan timeSpanDelay = TimeSpan.FromSeconds(1.0); + TimeSpan timeSpanDelay = TimeSpan.FromMilliseconds(1000); if (null != strDelay) { - double dblDelay = Double.Parse(strDelay); - if (dblDelay < 0.0) + int intDelay = Int32.Parse(strDelay); + if (intDelay < 0) { - dblDelay = 1.0; + intDelay = 1000; } - timeSpanDelay = TimeSpan.FromSeconds(dblDelay); + timeSpanDelay = TimeSpan.FromMilliseconds(intDelay); } string? strMaxLineLength = GetCmdOption(args, "--maxLineLength"); @@ -270,4 +270,4 @@ public static UserConfig UserConfigFromArgs(string[] args, string usage) ); } } -} +} \ No newline at end of file diff --git a/scenarios/java/jre/console/captioning/Captioning.java b/scenarios/java/jre/console/captioning/Captioning.java index 2ae3f4d86..65db351ff 100644 --- a/scenarios/java/jre/console/captioning/Captioning.java +++ b/scenarios/java/jre/console/captioning/Captioning.java @@ -31,7 +31,7 @@ public class Captioning { UserConfig _userConfig; - int _srtSequenceNumber = 0; + int _srtSequenceNumber = 1; Optional _previousCaption = Optional.empty(); Optional _previousEndTime = Optional.empty(); boolean _previousResultIsRecognized = false; diff --git a/scenarios/python/console/captioning/captioning.py b/scenarios/python/console/captioning/captioning.py index 5ffeede42..2fffcd048 100644 --- a/scenarios/python/console/captioning/captioning.py +++ b/scenarios/python/console/captioning/captioning.py @@ -65,10 +65,10 @@ Minimum is 20. Default is 37 (30 for Chinese). --lines LINES Set the number of lines for a caption to LINES. Minimum is 1. Default is 2. - --delay SECONDS How many SECONDS to delay the appearance of each caption. - Minimum is 0.0. Default is 1.0. - --remainTime SECONDS How many SECONDS a caption should remain on screen if it is not replaced by another. - Minimum is 0.0. Default is 1.0. + --delay MILLISECONDS How many MILLISECONDS to delay the appearance of each caption. + Minimum is 0. Default is 1000. + --remainTime MILLISECONDS How many MILLISECONDS a caption should remain on screen if it is not replaced by another. + Minimum is 0. Default is 1000. --quiet Suppress console output, except errors. --profanity OPTION Valid values: raw, remove, mask Default is mask. @@ -79,7 +79,7 @@ class Captioning(object) : def __init__(self) : self._user_config = user_config_helper.user_config_from_args(USAGE) - self._srt_sequence_number = 0 + self._srt_sequence_number = 1 self._previous_caption : Optional[caption_helper.Caption] = None self._previous_end_time : Optional[time] = None self._previous_result_is_recognized = False diff --git a/scenarios/python/console/captioning/user_config_helper.py b/scenarios/python/console/captioning/user_config_helper.py index 2123eaa99..4a2340513 100644 --- a/scenarios/python/console/captioning/user_config_helper.py +++ b/scenarios/python/console/captioning/user_config_helper.py @@ -89,21 +89,21 @@ def user_config_from_args(usage : str) -> helper.Read_Only_Dict : captioning_mode = CaptioningMode.REALTIME if cmd_option_exists("--realtime") and not cmd_option_exists("--offline") else CaptioningMode.OFFLINE - td_remain_time = timedelta(seconds=1.0) + td_remain_time = timedelta(milliseconds=1000) s_remain_time = get_cmd_option("--remainTime") if s_remain_time is not None : - flt_remain_time = float(s_remain_time) - if flt_remain_time < 0.0 : - flt_remain_time = 1.0 - td_remain_time = timedelta(seconds=flt_remain_time) + int_remain_time = float(s_remain_time) + if int_remain_time < 0 : + int_remain_time = 1000 + td_remain_time = timedelta(milliseconds=int_remain_time) - td_delay = timedelta(seconds=1.0) + td_delay = timedelta(milliseconds=1000) s_delay = get_cmd_option("--delay") if s_delay is not None : - flt_delay = float(s_delay) - if flt_delay < 0.0 : - flt_delay = 1.0 - td_delay = timedelta(seconds=flt_delay) + int_delay = float(s_delay) + if int_delay < 0 : + int_delay = 1000 + td_delay = timedelta(milliseconds=int_delay) int_max_line_length = helper.DEFAULT_MAX_LINE_LENGTH_SBCS s_max_line_length = get_cmd_option("--maxLineLength")