File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
- from fastapi import FastAPI , Request
1
+ from fastapi import FastAPI , Request , WebSocket
2
2
from fastapi .responses import Response
3
3
from twilio .twiml .messaging_response import MessagingResponse
4
4
import requests
5
5
import json
6
+ import base64
6
7
7
8
url = "https://apps.beam.cloud/e928s"
8
9
headers = {
@@ -23,7 +24,23 @@ async def root():
23
24
async def say_hello (name : str ):
24
25
return {"message" : f"Hello { name } " }
25
26
26
- @app .post ('/webhook' )
27
+ @app .post ('/webhook/call' )
28
+ async def webhook (request : Request ):
29
+ print ('ICI' , request )
30
+
31
+ @app .websocket ("/stream" )
32
+ async def websocket_endpoint (websocket : WebSocket ):
33
+ await websocket .accept ()
34
+ while True :
35
+ data = await websocket .receive_text ()
36
+ data = json .loads (data )
37
+ if 'payload' in data :
38
+ audio_data = base64 .b64decode (data ['payload' ])
39
+ print (type (audio_data ))
40
+ # Maintenant, `audio_data` contient l'audio brut que vous pouvez passer à votre fonction de transcription
41
+ # transcription = your_transcription_function(audio_data)
42
+
43
+ @app .post ('/webhook/whatsapp' )
27
44
async def webhook (request : Request ):
28
45
print ('ICI' , request )
29
46
You can’t perform that action at this time.
0 commit comments