Skip to content

Commit eaa5b9c

Browse files
committed
[feat]: audio features
1 parent 8e7b6e4 commit eaa5b9c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/ScriptToolkit/FileExtension.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,23 @@ public extension File {
9696
////////////////////////////////////////////////////////////////////////////////
9797
// MARK: - Audio Processing
9898

99-
public func slowDownAudio(newName: String, size: CGSize) {
99+
public func slowDownAudio(newName: String, size: CGSize) throws -> File {
100100
run("/usr/local/bin/sox", path, "-resize", "\(size.width)x\(size.height)",newName)
101+
return try File(path: newName)
102+
}
103+
104+
public func convertToWav(newName: String) throws -> File {
105+
run("ffmpeg", "-i", path, "-sample_rate 44100", newName.deletingPathExtension + ".wav")
106+
return try File(path: newName)
107+
}
108+
109+
public func convertToM4A(newName: String) throws -> File {
110+
run("ffmpeg", "-i", path, "-sample_rate 44100", newName.deletingPathExtension + ".m4a")
111+
return try File(path: newName)
112+
}
113+
114+
public func addSilence(newName: String) throws -> File {
115+
run("sox", "/Users/dan/Documents/[Development]/[Projects]/SwiftScripts/practise/silence.wav", path, newName)
116+
return try File(path: newName)
101117
}
102118
}

0 commit comments

Comments
 (0)