forked from stakira/OpenUtau
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from oxygen-dioxide/diffsinger-nomidi
diffsinger vocoder installer
- Loading branch information
Showing
7 changed files
with
92 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using SharpCompress.Archives; | ||
|
||
namespace OpenUtau.Core.DiffSinger { | ||
public class DiffSingerVocoderInstaller { | ||
public static string FileExt = ".dsvocoder"; | ||
public static void Install(string archivePath) { | ||
DsVocoderConfig vocoderConfig; | ||
using (var archive = ArchiveFactory.Open(archivePath)) { | ||
var configEntry = archive.Entries.First(e => e.Key == "vocoder.yaml"); | ||
if (configEntry == null) { | ||
throw new ArgumentException("missing vocoder.yaml"); | ||
} | ||
using (var stream = configEntry.OpenEntryStream()) { | ||
using var reader = new StreamReader(stream, Encoding.UTF8); | ||
vocoderConfig = Core.Yaml.DefaultDeserializer.Deserialize<DsVocoderConfig>(reader); | ||
} | ||
string name = vocoderConfig.name; | ||
var basePath = Path.Combine(PathManager.Inst.VocodersPath, name); | ||
foreach (var entry in archive.Entries) { | ||
if (entry.Key.Contains("..")) { | ||
// Prevent zipSlip attack | ||
continue; | ||
} | ||
var filePath = Path.Combine(basePath, entry.Key); | ||
Directory.CreateDirectory(Path.GetDirectoryName(filePath)); | ||
if (!entry.IsDirectory) { | ||
entry.WriteToFile(Path.Combine(basePath, entry.Key)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters