Skip to content

Commit 47377b6

Browse files
committed
[feat]: configurable paths
1 parent a4b28fe commit 47377b6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Sources/ScriptToolkit/FileExtension.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,22 @@ public extension File {
106106
// MARK: - Audio Processing
107107

108108
@discardableResult public func slowDownAudio(newName: String, percent: Float) throws -> File {
109-
run("/usr/local/bin/sox", path, newName, "tempo", "-s", String(percent))
109+
run(ScriptToolkit.soxPath, path, newName, "tempo", "-s", String(percent))
110110
return try File(path: newName)
111111
}
112112

113113
@discardableResult public func convertToWav(newName: String) throws -> File {
114-
run("/usr/local/bin/ffmpeg", "-i", path, "-sample_rate", "44100", newName.deletingPathExtension + ".wav")
114+
run(ScriptToolkit.ffmpegPath, "-i", path, "-sample_rate", "44100", newName.deletingPathExtension + ".wav")
115115
return try File(path: newName)
116116
}
117117

118118
@discardableResult public func convertToM4A(newName: String) throws -> File {
119-
run("/usr/local/bin/ffmpeg", "-i", path, "-sample_rate", "44100", newName.deletingPathExtension + ".m4a")
119+
run(ScriptToolkit.ffmpegPath, "-i", path, "-sample_rate", "44100", newName.deletingPathExtension + ".m4a")
120120
return try File(path: newName)
121121
}
122122

123123
@discardableResult public func addSilence(newName: String) throws -> File {
124-
run("/usr/local/bin/sox", "/Users/dan/Documents/[Development]/[Projects]/SwiftScripts/practise/silence.wav", path, newName)
124+
run(ScriptToolkit.soxPath, ScriptToolkit.silenceFilePath, path, newName)
125125
return try File(path: newName)
126126
}
127127
}

Sources/ScriptToolkit/ScriptToolkit.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ import Files
1010
import SwiftShell
1111

1212
public struct ScriptToolkit {
13+
14+
// Setup of absolute paths
15+
static let ffmpegPath = "/usr/local/bin/ffmpeg"
16+
static let soxPath = "/usr/local/bin/sox"
17+
static let silenceFilePath = "/Users/dan/Documents/[Development]/[Projects]/SwiftScripts/practise/silence.wav"
18+
1319
public static let dateFormatter: DateFormatter = {
1420
let formatter = DateFormatter()
1521
formatter.dateFormat = "YYYY-MM-dd"

0 commit comments

Comments
 (0)