Skip to content

Commit 97cfff0

Browse files
committed
missing snippets added
1 parent 3afff81 commit 97cfff0

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed

common/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from sinch import SinchClient
2+
3+
sinch_client = SinchClient(
4+
application_key="YOUR_application_key",
5+
application_secret="YOUR_application_secret"
6+
)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
from sinch import SinchClient
3+
4+
sinch_client = SinchClient(
5+
application_key=os.getenv("APPLICATION_KEY"),
6+
application_secret=os.getenv("APPLICATION_SECRET")
7+
)

verification/verification_domain.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from sinch import SinchClient
2+
from sinch.domains.verification import Verification
3+
4+
sinch_client = SinchClient(
5+
application_key="YOUR_application_key",
6+
application_secret="YOUR_application_secret"
7+
)
8+
9+
verification_client = Verification(sinch_client)

voice/text_to_speech.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from sinch import SinchClient
2+
3+
sinch_client = SinchClient(
4+
application_key="YOUR_application_key",
5+
application_secret="YOUR_application_secret"
6+
)
7+
8+
response = sinch_client.voice.callouts.text_to_speech(
9+
destination={
10+
"type":"number",
11+
"endpoint":"YOUR_phone_number"
12+
},
13+
text="Hello, this is a call from Sinch. Congratulations! You made your first call.")
14+
15+
print(response)

voice/text_to_speech_using_rest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import requests
2+
3+
key = ""
4+
secret = ""
5+
from_number = ""
6+
to = ""
7+
locale = ""
8+
url = "https://calling.api.sinch.com/calling/v1/callouts"
9+
10+
payload = {
11+
"method": "ttsCallout",
12+
"ttsCallout": {
13+
"cli": from_number,
14+
"destination": {
15+
"type": "number",
16+
"endpoint": to
17+
},
18+
"locale": locale,
19+
"text": "Hello, this is a call from Sinch. Congratulations! You made your first call."
20+
}
21+
}
22+
23+
headers = {"Content-Type": "application/json"}
24+
25+
response = requests.post(url, json=payload, headers=headers, auth=(key, secret))
26+
27+
data = response.json()
28+
print(data)

voice/voice_domain.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from sinch import Client
2+
from sinch.domains.voice import Voice
3+
4+
sinch_client = Client(
5+
application_key="YOUR_application_key",
6+
application_secret="YOUR_application_secret"
7+
)
8+
9+
voice_client = Voice(sinch_client)

0 commit comments

Comments
 (0)