mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 20:07:20 +00:00
Added transcription of audio and video files to local data sources (#1081)
Co-authored-by: Paul Koudelka <106623909+PaulKoudelka@users.noreply.github.com>
This commit is contained in:
1 parent
8642ce2d81
commit
752f7d828a
82 files changed
+3231
-302
No files matched your search
@@ -80,6 +80,33 @@ internal static class FileNamePatterns
|
||||
&& FileSystemName.MatchesSimpleExpression(pattern, fileName, ignoreCase: true));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether the patterns may select audio or video files, which a data source sends to the transcription provider.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Deliberately cautious, since it answers without looking at a single file: a pattern which
|
||||
/// may match any extension, such as * or meeting*, counts. The selectors never select media.
|
||||
/// </remarks>
|
||||
/// <param name="patterns">The parsed patterns.</param>
|
||||
/// <returns>True when audio or video files may match.</returns>
|
||||
public static bool MaySelectMedia(IReadOnlyList<string> patterns) => patterns.Any(MaySelectMedia);
|
||||
|
||||
private static bool MaySelectMedia(string pattern)
|
||||
{
|
||||
if (pattern.StartsWith(SELECTOR_DELIMITER) && pattern.EndsWith(SELECTOR_DELIMITER))
|
||||
return false;
|
||||
|
||||
var extensionStart = pattern.LastIndexOf('.');
|
||||
if (extensionStart < 0)
|
||||
return pattern.IndexOfAny(['*', '?']) >= 0;
|
||||
|
||||
var extension = pattern[(extensionStart + 1)..];
|
||||
if (extension.IndexOfAny(['*', '?']) >= 0)
|
||||
return true;
|
||||
|
||||
return FileTypes.IsAllowedPath($"media.{extension}", FileTypes.AUDIO, FileTypes.VIDEO);
|
||||
}
|
||||
|
||||
public static bool AreEquivalent(IReadOnlyCollection<string>? left, IReadOnlyCollection<string>? right)
|
||||
{
|
||||
if (left is null || right is null)
|
||||
|
||||
Reference in new issue
Block a user