Compare commits

..

13 Commits

Author SHA1 Message Date
Bel LaPointe
001fef8bbc ?room s 2025-10-15 00:12:19 -06:00
Bel LaPointe
a9004c38af remove quote file 2025-10-14 23:59:46 -06:00
bel
b34c980ea5 fade old text 2025-10-14 23:46:48 -06:00
bel
78fd4fd28b not sure what is left but ship 2025-10-14 23:37:15 -06:00
bel
b89d8e3d3f no log 2025-10-14 23:30:04 -06:00
bel
c4a21861cd listen 2025-10-14 23:28:44 -06:00
bel
d5c3a52215 sender can choose voice and pitch and rate 2025-10-14 23:21:24 -06:00
bel
bc1f7779d7 less ew to look at 2025-10-14 22:49:40 -06:00
bel
49880c837d love 2025-10-14 22:13:55 -06:00
bel
4dd5a40dfe ew 2025-10-14 22:09:16 -06:00
bel
13b583a77e a chat room 2025-10-14 22:04:30 -06:00
bel
c9c4800d68 it is something 2025-10-14 21:38:32 -06:00
bel
d793e13361 stubs 2025-10-14 21:34:17 -06:00
3 changed files with 22 additions and 59 deletions

View File

@@ -57,7 +57,7 @@
}
}
ws = new WebSocket(`${window.location.protocol == "https:" ? "wss" : "ws"}://${window.location.host}/ws${window.location.search}`);
ws = new WebSocket("ws://"+window.location.host+"/ws"+window.location.search);
ws.onopen = function(evt) {
print("READY");
}
@@ -69,25 +69,21 @@
console.log("evt.data:", evt.data)
const data = JSON.parse(evt.data);
if (data.Text) {
const utterThis = new SpeechSynthesisUtterance(data.Text);
const utterThis = new SpeechSynthesisUtterance(data.Text);
const idx = data.VoiceIdx || 0;
utterThis.voice = voices[idx];
const idx = data.VoiceIdx || 0;
utterThis.voice = voices[idx];
if (data.Pitch) {
utterThis.pitch = data.Pitch
}
if (data.Rate) {
utterThis.rate = data.Rate
}
window.speechSynthesis.speak(utterThis);
print(data.Text);
} else if (data.QuietText) {
print(data.QuietText);
if (data.Pitch) {
utterThis.pitch = data.Pitch
}
if (data.Rate) {
utterThis.rate = data.Rate
}
window.speechSynthesis.speak(utterThis);
print(data.Text);
}
ws.onerror = function(evt) {
print("ERROR: " + evt.data);

View File

@@ -1,10 +1,9 @@
package server
type message struct {
Text string
QuietText string
Pitch int
Rate float64
VoiceIdx int
room string
Text string
Pitch int
Rate float64
VoiceIdx int
room string
}

View File

@@ -1,7 +1,6 @@
package server
import (
"fmt"
"log"
"net/http"
)
@@ -32,6 +31,9 @@ func (s *Server) WS(w http.ResponseWriter, r *http.Request) error {
}
defer sess.Close()
log.Println("someone has joined", sess.room)
defer log.Println("someone has left", sess.room)
sess.cb = func(m message) error {
for i := range s.sessions {
if s.sessions[i].id != sess.id && s.sessions[i].room == sess.room {
@@ -44,42 +46,8 @@ func (s *Server) WS(w http.ResponseWriter, r *http.Request) error {
return nil
}
func() {
s.sessions = append(s.sessions, sess)
n := 0
for i := range s.sessions {
if s.sessions[i].room == sess.room {
n += 1
}
}
for i := range s.sessions {
if s.sessions[i].room == sess.room {
if s.sessions[i].id == sess.id {
s.sessions[i].scatterc <- message{QuietText: fmt.Sprintf("you have joined %v people", n-1)}
} else {
s.sessions[i].scatterc <- message{QuietText: fmt.Sprintf("there is now %v people", n)}
}
}
}
}()
s.sessions = append(s.sessions, sess)
defer func() {
n := 0
for i := range s.sessions {
if s.sessions[i].room == sess.room {
n += 1
}
}
n -= 1
for i := range s.sessions {
if s.sessions[i].room == sess.room {
if s.sessions[i].id == sess.id {
} else {
s.sessions[i].scatterc <- message{QuietText: fmt.Sprintf("there is now %v people", n)}
}
}
}
for i := range s.sessions {
if s.sessions[i].id == sess.id {
s.sessions = append(s.sessions[:i], s.sessions[i+1:]...)