diff --git a/manifest/ncb-tts.yaml b/manifest/ncb-tts.yaml new file mode 100644 index 0000000..0ab3749 --- /dev/null +++ b/manifest/ncb-tts.yaml @@ -0,0 +1,56 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ncb-tts-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: ncb-tts + template: + metadata: + labels: + app: ncb-tts + spec: + containers: + - name: redis + image: redis:7.0.4-alpine + ports: + - containerPort: 6379 + name: ncb-redis + volumeMounts: + - name: ncb-redis-pvc + mountPath: /data + - name: tts + image: ghcr.io/morioka22/ncb-tts-r2 + volumeMounts: + - name: gcp-credentials + mountPath: /ncb-tts-r2/credentials.json + subPath: credentials.json + env: + - name: NCB_REDIS_URL + value: "redis://localhost:6379/" + - name: NCB_PREFIX + value: "t2!" + - name: NCB_TOKEN + valueFrom: + secretKeyRef: + name: ncb-secret + key: BOT_TOKEN + - name: NCB_VOICEVOX_KEY + valueFrom: + secretKeyRef: + name: ncb-secret + key: VOICEVOX_KEY + - name: NCB_APP_ID + valueFrom: + secretKeyRef: + name: ncb-secret + key: APP_ID + volumes: + - name: ncb-redis-pvc + persistentVolumeClaim: + claimName: ncb-redis-pvc + - name: gcp-credentials + secret: + secretName: gcp-credentials diff --git a/manifest/pvc.yaml b/manifest/pvc.yaml new file mode 100644 index 0000000..2a05486 --- /dev/null +++ b/manifest/pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: ncb-redis-pvc + labels: + app: ncb-redis +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 3Gi diff --git a/src/tts/validator.rs b/src/tts/validator.rs index 8e78807..4a3b354 100644 --- a/src/tts/validator.rs +++ b/src/tts/validator.rs @@ -2,5 +2,7 @@ use regex::Regex; pub fn remove_url(text: String) -> String { let url_regex = Regex::new(r"(http://|https://){1}[\w\.\-/:\#\?=\&;%\~\+]+").unwrap(); - url_regex.replace_all(&text, " URL ").to_string() + let code_regex = Regex::new(r"```(.*)```").unwrap(); + let text = url_regex.replace_all(&text, " URL ").to_string(); + code_regex.replace_all(&text, "code").to_string() }