Skip to content

Commit

Permalink
start cleanning
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet committed Nov 1, 2024
1 parent a9863a4 commit 40f089d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,5 @@ jobs:
kubectl apply -f ia-worker-service.yaml
kubectl apply -f slimfaas-deployment.yaml
kubectl apply -f slimfaas-ingress.yaml
kubectl apply -f redis-deployment.yaml
kubectl apply -f redis-deployment.yaml
kubectl apply -f hpas.yaml
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ docker-compose up
# Roadmap
- [infrastructure] Configure a URL with HTTPS on Kubernetes
- [ia-worker] Set up GPU on Kubernetes
- [infrastructure] For scaling, add keda to scale from GPU consumption or queue length
- [infrastructure] For scaling, add keda to scale from GPU consumption or queue length or wait Slimfaas to add this feature
- Set up Redis with high availability
- Set up Slimfaas with high availability
- Add monitoring
- Add alerting
- Add logging
Expand Down
32 changes: 32 additions & 0 deletions deploy/kubernetes/hpas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: ia-worker-hpa
namespace: transcriptor
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: ia-worker
minReplicas: 1
maxReplicas: 5
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
behavior:
scaleUp:
stabilizationWindowSeconds: 400
policies:
- type: Pods
value: 1
periodSeconds: 15
scaleDown:
stabilizationWindowSeconds: 600
policies:
- type: Percent
value: 50
periodSeconds: 60
4 changes: 2 additions & 2 deletions deploy/kubernetes/ia-worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ spec:
value: "production"
resources:
limits:
memory: "2000Mi"
memory: "2400Mi"
cpu: "2000m"
requests:
ephemeral-storage: "1000Mi"
memory: "2000Mi"
memory: "2400Mi"
cpu: "500m"
4 changes: 2 additions & 2 deletions production/webapp/src/AudioRecorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class AudioRecorder {
this.onDataAvailable = options.onDataAvailable || function() {};
this.onError = options.onError || function() {};
this.silenceDelay = options.silenceDelay || 200;
this.speechThreshold = options.speechThreshold || 10;
this.silenceThreshold = options.silenceThreshold || 4;
this.speechThreshold = options.speechThreshold || 12;
this.silenceThreshold = options.silenceThreshold || 8;

// Nouvelle propriété pour contrôler la détection de la parole
this.isDetectingSpeech = false;
Expand Down
13 changes: 10 additions & 3 deletions production/webapp/src/AudioRecorderComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const sendAudioChunk= (fetch, baseUrl) => (chunk, clientId, chunkIndex) => {
});
}

let iniAsyncPromise = null;

const AudioRecorderComponent = ({}) => {
const [status, setStatus] = useState('En attente de la parole...');
const [isRecording, setIsRecording] = useState(false);
Expand All @@ -39,6 +41,9 @@ const AudioRecorderComponent = ({}) => {
const { fetch } = useOidcFetch();

useEffect(() => {
if (iniAsyncPromise) {
return;
}
console.log('Initialisation de l\'enregistreur audio');
console.log('URL de base :', baseUrl);
// Nettoyage des ressources précédentes
Expand Down Expand Up @@ -79,8 +84,7 @@ const AudioRecorderComponent = ({}) => {
const updatedTranscripts = [...prev, data];
console.log('Transcription reçue :', data.transcript);

const ordered_transcripts = updatedTranscripts.sort((a, b) => a.chunk_index - b.chunk_index);
return ordered_transcripts;
return updatedTranscripts.sort((a, b) => a.chunk_index - b.chunk_index);
});
};

Expand Down Expand Up @@ -131,7 +135,10 @@ const AudioRecorderComponent = ({}) => {
recorderRef.current = recorder;
recorder.init();
}
initAsync();
iniAsyncPromise = initAsync();
iniAsyncPromise.then(() => {
iniAsyncPromise = null;
});

return () => {
if (recorderRef.current) {
Expand Down

0 comments on commit 40f089d

Please sign in to comment.