-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add get info/control media voice snippets
- Loading branch information
Showing
9 changed files
with
142 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
import time | ||
import os | ||
from os.path import join, dirname | ||
from pprint import pprint | ||
from time import sleep | ||
from dotenv import load_dotenv | ||
import vonage | ||
|
||
dotenv_path = join(dirname(__file__), "../.env") | ||
dotenv_path = join(dirname(__file__), '../.env') | ||
load_dotenv(dotenv_path) | ||
|
||
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get("VONAGE_APPLICATION_PRIVATE_KEY_PATH") | ||
UUID = os.environ.get("UUID") | ||
client = vonage.Client( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
VONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID') | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get( | ||
'VONAGE_APPLICATION_PRIVATE_KEY_PATH' | ||
) | ||
|
||
response = client.voice.update_call(UUID, action="earmuff") | ||
pprint(response) | ||
time.sleep(5) | ||
response = client.voice.update_call(UUID, action="unearmuff") | ||
pprint(response) | ||
CALL_UUID = os.environ.get('CALL_UUID') | ||
|
||
from vonage import Auth, Vonage | ||
|
||
client = Vonage( | ||
Auth( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
) | ||
|
||
client.voice.earmuff(CALL_UUID) | ||
sleep(5) | ||
client.voice.unearmuff(CALL_UUID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from pprint import pprint | ||
import os | ||
from os.path import join, dirname | ||
from dotenv import load_dotenv | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
import time | ||
import os | ||
from os.path import join, dirname | ||
from pprint import pprint | ||
import vonage | ||
from time import sleep | ||
from dotenv import load_dotenv | ||
|
||
dotenv_path = join(dirname(__file__), "../.env") | ||
dotenv_path = join(dirname(__file__), '../.env') | ||
load_dotenv(dotenv_path) | ||
|
||
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get("VONAGE_APPLICATION_PRIVATE_KEY_PATH") | ||
UUID = os.environ.get("UUID") | ||
VONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID') | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get( | ||
'VONAGE_APPLICATION_PRIVATE_KEY_PATH' | ||
) | ||
|
||
CALL_UUID = os.environ.get('CALL_UUID') | ||
|
||
from vonage import Auth, Vonage | ||
|
||
client = vonage.Client( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH | ||
client = Vonage( | ||
Auth( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
) | ||
|
||
response = client.voice.update_call(UUID, action="mute") | ||
pprint(response) | ||
time.sleep(5) | ||
response = client.voice.update_call(UUID, action="unmute") | ||
pprint(response) | ||
client.voice.mute(CALL_UUID) | ||
sleep(5) | ||
client.voice.unmute(CALL_UUID) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,34 @@ | ||
import os | ||
from os.path import join, dirname | ||
from pprint import pprint | ||
from dotenv import load_dotenv | ||
import vonage | ||
|
||
dotenv_path = join(dirname(__file__), "../.env") | ||
dotenv_path = join(dirname(__file__), '../.env') | ||
load_dotenv(dotenv_path) | ||
|
||
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get("VONAGE_APPLICATION_PRIVATE_KEY_PATH") | ||
VONAGE_CALL_UUID = os.environ.get("UUID") | ||
VONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID') | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get( | ||
'VONAGE_APPLICATION_PRIVATE_KEY_PATH' | ||
) | ||
|
||
CALL_UUID = os.environ.get('CALL_UUID') | ||
|
||
from vonage import Auth, Vonage | ||
from vonage_voice.models import AudioStreamOptions, CallMessage | ||
|
||
|
||
client = Vonage( | ||
Auth( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
) | ||
|
||
client = vonage.Client( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH | ||
response: CallMessage = client.voice.play_audio_into_call( | ||
CALL_UUID, | ||
audio_stream_options=AudioStreamOptions( | ||
stream_url=['https://example.com/ringtone.mp3'] | ||
), | ||
) | ||
|
||
stream_url = 'https://nexmo-community.github.io/ncco-examples/assets/voice_api_audio_streaming.mp3' | ||
client.voice.send_audio(VONAGE_CALL_UUID, stream_url=[stream_url]) | ||
pprint(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
import os | ||
from os.path import join, dirname | ||
from pprint import pprint | ||
from dotenv import load_dotenv | ||
import vonage | ||
|
||
dotenv_path = join(dirname(__file__), "../.env") | ||
dotenv_path = join(dirname(__file__), '../.env') | ||
load_dotenv(dotenv_path) | ||
|
||
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get("VONAGE_APPLICATION_PRIVATE_KEY_PATH") | ||
VONAGE_CALL_UUID = os.environ.get("UUID") | ||
VONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID') | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get( | ||
'VONAGE_APPLICATION_PRIVATE_KEY_PATH' | ||
) | ||
|
||
CALL_UUID = os.environ.get('CALL_UUID') | ||
|
||
from vonage import Auth, Vonage | ||
from vonage_voice.models import CallMessage | ||
|
||
client = vonage.Client( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
|
||
client = Vonage( | ||
Auth( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
) | ||
|
||
client.voice.send_dtmf(VONAGE_CALL_UUID, digits='1234') | ||
response: CallMessage = client.voice.play_dtmf_into_call(uuid=CALL_UUID, dtmf='1234p*#') | ||
|
||
pprint(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import os | ||
from os.path import join, dirname | ||
from pprint import pprint | ||
from dotenv import load_dotenv | ||
import vonage | ||
|
||
dotenv_path = join(dirname(__file__), "../.env") | ||
dotenv_path = join(dirname(__file__), '../.env') | ||
load_dotenv(dotenv_path) | ||
|
||
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get("VONAGE_APPLICATION_PRIVATE_KEY_PATH") | ||
VONAGE_CALL_UUID = os.environ.get("UUID") | ||
VONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID') | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get( | ||
'VONAGE_APPLICATION_PRIVATE_KEY_PATH' | ||
) | ||
|
||
CALL_UUID = os.environ.get('CALL_UUID') | ||
|
||
from vonage import Auth, Vonage | ||
from vonage_voice.models import CallMessage, TtsStreamOptions | ||
|
||
|
||
client = Vonage( | ||
Auth( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
) | ||
|
||
client = vonage.Client( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
response: CallMessage = client.voice.play_tts_into_call( | ||
uuid=CALL_UUID, tts_options=TtsStreamOptions(text='Hello from Vonage.') | ||
) | ||
|
||
client.voice.send_speech(VONAGE_CALL_UUID, text='Hello from Vonage') | ||
pprint(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
#!/usr/bin/env python3 | ||
from pprint import pprint | ||
import os | ||
from os.path import join, dirname | ||
from dotenv import load_dotenv | ||
import vonage | ||
|
||
dotenv_path = join(dirname(__file__), "../.env") | ||
dotenv_path = join(dirname(__file__), '../.env') | ||
load_dotenv(dotenv_path) | ||
|
||
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get("VONAGE_APPLICATION_PRIVATE_KEY_PATH") | ||
VONAGE_CALL_UUID = os.environ.get("UUID") | ||
VONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID') | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get( | ||
'VONAGE_APPLICATION_PRIVATE_KEY_PATH' | ||
) | ||
|
||
client = vonage.Client( | ||
CALL_UUID = os.environ.get('CALL_UUID') | ||
|
||
from vonage import Auth, Vonage | ||
from vonage_voice.models import CallInfo | ||
|
||
client = Vonage( | ||
Auth( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
) | ||
|
||
# Note call can be made to current call or a completed call | ||
response = client.voice.get_call(VONAGE_CALL_UUID) | ||
response: CallInfo = client.voice.get_call(CALL_UUID) | ||
pprint(response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
from datetime import datetime, timedelta, timezone | ||
from pprint import pprint | ||
import os | ||
from os.path import join, dirname | ||
from datetime import datetime, timedelta | ||
import vonage | ||
from dotenv import load_dotenv | ||
|
||
dotenv_path = join(dirname(__file__), "../.env") | ||
dotenv_path = join(dirname(__file__), '../.env') | ||
load_dotenv(dotenv_path) | ||
|
||
VONAGE_APPLICATION_ID = os.environ.get("VONAGE_APPLICATION_ID") | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get("VONAGE_APPLICATION_PRIVATE_KEY_PATH") | ||
VONAGE_APPLICATION_ID = os.environ.get('VONAGE_APPLICATION_ID') | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = os.environ.get( | ||
'VONAGE_APPLICATION_PRIVATE_KEY_PATH' | ||
) | ||
|
||
from vonage import Auth, Vonage | ||
from vonage_voice.models import ListCallsFilter | ||
|
||
client = vonage.Client( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
client = Vonage( | ||
Auth( | ||
application_id=VONAGE_APPLICATION_ID, | ||
private_key=VONAGE_APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
) | ||
|
||
NOW = datetime.utcnow() | ||
DATE_END = NOW.replace(microsecond=0).isoformat()+"Z" | ||
DATE_START = (NOW - timedelta(hours=24, minutes=00)).replace(microsecond=0).isoformat()+"Z" | ||
|
||
response = client.voice.get_calls(date_start=DATE_START, date_end=DATE_END) | ||
calls = response['_embedded']['calls'] | ||
NOW = datetime.now(timezone.utc) | ||
DATE_END = NOW.replace(microsecond=0).isoformat() | ||
DATE_START = (NOW - timedelta(hours=24, minutes=00)).replace(microsecond=0).isoformat() | ||
|
||
calls, _ = client.voice.list_calls( | ||
ListCallsFilter(date_start=DATE_START, date_end=DATE_END) | ||
) | ||
|
||
for call in calls: | ||
pprint(call) |