Skip to content

Commit

Permalink
Release V0.4.1 (#43)
Browse files Browse the repository at this point in the history
* rm tts debug

* version update

* update gha

* docker build

* go mod tidy

* rm play audio to test on arm processor

* rm play audio to test on arm processor

* clean dockerfile
  • Loading branch information
seemywingz authored Dec 21, 2024
1 parent e8ed2e4 commit b1efe04
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 328 deletions.
8 changes: 5 additions & 3 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ OPENAI_API_KEY={YOUR OPENAI API KEY}
DISCORD_API_KEY={YOUR DISCORD BOT API KEY}
```



## Ponder a single thought
### CLI
```bash
Expand All @@ -35,6 +33,10 @@ ponder "What is AI"
```bash
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY ghcr.io/seemywingz/ponder:latest "What is AI"
```
or
```bash
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY -e DISCORD_API_KEY=$DISCORD_API_KEY ghcr.io/seemywingz/ponder:latest discord-bot
```
#### Example Output
```bash
AI, or Artificial Intelligence, refers to the simulation of human intelligence processes by machines, especially computer systems. These processes include learning (the acquisition of information and rules for using the information), reasoning (using the rules to reach approximate or definite conclusions), and self-correction.
Expand Down Expand Up @@ -71,7 +73,7 @@ ponder image "a ferocious cat with wings and fire"
Ponder
GitHub: https://github.com/seemywingz/ponder
App Version: v0.4.0
App Version: v0.4.1
Ponder uses OpenAI's API to generate text responses to user input.
Or whatever else you can think of. 🤔
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/dockerBuildX.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,29 @@ jobs:

steps:
- name: GitHub Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Docker Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Docker Set up Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Docker Login
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ENV APP_NAME=ponder
ENV WORKDIR=/app
WORKDIR $WORKDIR
COPY . .
RUN apk add --no-cache build-base pkgconfig alsa-lib-dev
RUN go mod download
RUN go build -o /$APP_NAME

Expand Down
4 changes: 2 additions & 2 deletions cmd/adventure.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ func adventureImage(prompt string) {

func narratorSay(text string) {
if narrate {
audioData := tts(text)
// audioData := tts(text)
spinner.Stop()
fmt.Println("🗣️ Narrator: ", text)
playAudio(audioData)
// playAudio(audioData)
}
spinner.Stop()
}
Expand Down
18 changes: 10 additions & 8 deletions cmd/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,24 @@ var chatCmd = &cobra.Command{
var err error
if convo {
for {
response, audio := chatResponse(prompt)
response, _ := chatResponse(prompt)
// response, audio := chatResponse(prompt)
fmt.Println("\nPonder:")
syntaxHighlight(response)
if narrate {
playAudio(audio)
}
// if narrate {
// playAudio(audio)
// }
fmt.Print("\nYou:\n ")
prompt, err = getUserInput()
catchErr(err, "warn")
}
} else {
response, audio := chatResponse(prompt)
response, _ := chatResponse(prompt)
// response, audio := chatResponse(prompt)
syntaxHighlight(response)
if narrate {
playAudio(audio)
}
// if narrate {
// playAudio(audio)
// }
}
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

var ponderMessages = []goai.Message{}
var APP_VERSION = "v0.4.0"
var APP_VERSION = "v0.4.1"
var ai *goai.Client

var verbose,
Expand Down
11 changes: 5 additions & 6 deletions cmd/tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package cmd

import (
"bytes"
"fmt"
"io"
"os"

Expand All @@ -26,10 +25,11 @@ var ttsCmd = &cobra.Command{
return checkArgs(args)
},
Run: func(cmd *cobra.Command, args []string) {
audio := tts(prompt)
if audio != nil {
playAudio(audio)
}
tts(prompt)
// audio := tts(prompt)
// if audio != nil {
// playAudio(audio)
// }
},
}

Expand All @@ -40,7 +40,6 @@ func init() {

func tts(text string) []byte {
ai.Voice = voice
fmt.Println("Generating audio...", text)
audioData, err := ai.TTS(text)
catchErr(err, "fatal")
if audioFile != "" {
Expand Down
62 changes: 29 additions & 33 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"bytes"
"fmt"
"io"
"net/url"
"os"
"path/filepath"
Expand All @@ -16,9 +15,6 @@ import (
"github.com/alecthomas/chroma/formatters"
"github.com/alecthomas/chroma/lexers"
"github.com/alecthomas/chroma/styles"
"github.com/faiface/beep"
"github.com/faiface/beep/mp3"
"github.com/faiface/beep/speaker"
"github.com/pterm/pterm"
)

Expand Down Expand Up @@ -187,32 +183,32 @@ func trace() {
}

// playAudio plays audio from a byte slice.
func playAudio(audioContent []byte) {
if verbose {
fmt.Println("🔊 Playing audio...")
}

// Create an io.Reader from the byte slice
reader := bytes.NewReader(audioContent)

// Wrap the reader in a NopCloser to make it an io.ReadCloser.
readCloser := io.NopCloser(reader)

// Decode the MP3 stream.
streamer, format, err := mp3.Decode(readCloser)
catchErr(err)
defer streamer.Close()

// Initialize the speaker with the sample rate of the audio and a buffer size.
err = speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
catchErr(err)

// Play the decoded audio.
done := make(chan bool)
speaker.Play(beep.Seq(streamer, beep.Callback(func() {
done <- true
})))

// Wait for the audio to finish playing.
<-done
}
// func playAudio(audioContent []byte) {
// if verbose {
// fmt.Println("🔊 Playing audio...")
// }

// // Create an io.Reader from the byte slice
// reader := bytes.NewReader(audioContent)

// // Wrap the reader in a NopCloser to make it an io.ReadCloser.
// readCloser := io.NopCloser(reader)

// // Decode the MP3 stream.
// streamer, format, err := mp3.Decode(readCloser)
// catchErr(err)
// defer streamer.Close()

// // Initialize the speaker with the sample rate of the audio and a buffer size.
// err = speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))
// catchErr(err)

// // Play the decoded audio.
// done := make(chan bool)
// speaker.Play(beep.Seq(streamer, beep.Callback(func() {
// done <- true
// })))

// // Wait for the audio to finish playing.
// <-done
// }
10 changes: 0 additions & 10 deletions files/config
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ openAI_chat_systemMessage: |
You're designed to understand context, follow conversations, handle complex instructions, and learn from interactions.
Your goal is to make the user's experience as seamless and productive as possible.

radio_notificationSound: "~/.ponder/audio/notify.mp3"

# radio_systemMessage: |
# You are an AI ham radio operator.
# Your call sign is WSCE496.
# Use HAM radio appropriate etiquette.
# Use the NATO phonetic alphabet when reciting letters, and numbers.
# You are knowledgeable in all things radio and electronics.
# When returning chat responses end all text output with '...'

discord_message_context_count: 15
discord_bot_systemMessage: |
You are Ponder.
Expand Down
9 changes: 0 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ go 1.23
require (
github.com/alecthomas/chroma v0.10.0
github.com/bwmarrin/discordgo v0.28.1
github.com/faiface/beep v1.1.0
github.com/pterm/pterm v0.12.80
github.com/seemywingz/goai v0.0.0-20240428060229-cce9aefb4824
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
periph.io/x/conn/v3 v3.7.1
periph.io/x/host/v3 v3.8.2
)

require (
Expand All @@ -23,16 +20,13 @@ require (
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hajimehoshi/go-mp3 v0.3.0 // indirect
github.com/hajimehoshi/oto v0.7.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
Expand All @@ -45,9 +39,6 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 // indirect
golang.org/x/exp/shiny v0.0.0-20241217172543-b2144cdd0a67 // indirect
golang.org/x/image v0.23.0 // indirect
golang.org/x/mobile v0.0.0-20241213221354-a87c1cf6cf46 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
Expand Down
Loading

0 comments on commit b1efe04

Please sign in to comment.