Skip to content

Commit

Permalink
Adding TTS to GalaktaGlare
Browse files Browse the repository at this point in the history
  • Loading branch information
simplyYan authored Jun 14, 2024
1 parent 61238c1 commit f98fad1
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/GalaktaGlareTTS/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/simplyYan/GalaktaGlare/src/GalaktaGlareTTS

go 1.22.4
29 changes: 29 additions & 0 deletions src/GalaktaGlareTTS/recognize.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package galaktaglaretts

import (
"fmt"
"os/exec"
"runtime"
)

func RecognizeSpeech() (string, error) {
var cmd *exec.Cmd

switch runtime.GOOS {
case "linux":
cmd = exec.Command("bash", "scripts/recognize_linux.sh")
case "darwin":
cmd = exec.Command("bash", "scripts/recognize_macos.sh")
case "windows":
cmd = exec.Command("cmd", "/C", "scripts/recognize_windows.bat")
default:
return "", fmt.Errorf("unsupported platform")
}

output, err := cmd.CombinedOutput()
if err != nil {
return "", fmt.Errorf("failed to recognize speech: %v, output: %s", err, output)
}

return string(output), nil
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions src/GalaktaGlareTTS/tts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package galaktaglaretts

import (
"fmt"
"os/exec"
"runtime"
)

func TextToSpeech(text string) error {
var cmd *exec.Cmd

switch runtime.GOOS {
case "linux":
cmd = exec.Command("bash", "scripts/tts_linux.sh", text)
case "darwin":
cmd = exec.Command("bash", "scripts/tts_macos.sh", text)
case "windows":
cmd = exec.Command("cmd", "/C", "scripts/tts_windows.bat", text)
default:
return fmt.Errorf("unsupported platform")
}

output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to execute TTS: %v, output: %s", err, output)
}

return nil
}

0 comments on commit f98fad1

Please sign in to comment.