-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEVEXP-373: voice textToSpeech snippet (#1)
* TextToSppech snippet * 'numbers.available.list' snippet
- Loading branch information
Showing
6 changed files
with
179 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Compilation | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Building | ||
run: | | ||
./compile.sh | ||
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,2 +1,4 @@ | ||
# sinch-sdk-java-snippets | ||
Sinch Java SDK Code Snippets Repository | ||
|
||
This repository contains code snippets related to [Sinch JAVA SDK](https://github.com/sinch/sinch-sdk-java) |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
|
||
(cd snippets && mvn clean spotless:apply compile) | ||
|
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package numbers; | ||
|
||
import com.sinch.sdk.domains.numbers.*; | ||
import com.sinch.sdk.domains.numbers.models.NumberType; | ||
import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberListAllRequestParameters; | ||
import java.util.logging.Logger; | ||
|
||
public class List { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(List.class.getName()); | ||
|
||
public void list(NumbersService numbersService) { | ||
|
||
var availableNumbersService = numbersService.available(); | ||
|
||
var regionCode = "US"; | ||
var type = NumberType.LOCAL; | ||
|
||
var parameters = | ||
AvailableNumberListAllRequestParameters.builder() | ||
.setRegionCode(regionCode) | ||
.setType(type) | ||
.build(); | ||
|
||
var response = availableNumbersService.list(parameters); | ||
|
||
response.iterator() | ||
.forEachRemaining( | ||
number -> | ||
LOGGER.info(String.format("Available number details: %s", number))); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.sinch.sdk.archetypes</groupId> | ||
<artifactId>sinch-java-sdk-client-snippets</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>Sinch Java SDK Client Snippets</name> | ||
|
||
<properties> | ||
<sinch.sdk.java.version>[1.0.0,)</sinch.sdk.java.version> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
<maven.compiler.version>3.8.0</maven.compiler.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<executions> | ||
<execution> | ||
<id>add-sources</id> | ||
<phase>generate-sources</phase> | ||
<goals> | ||
<goal>add-source</goal> | ||
</goals> | ||
<configuration> | ||
<sources> | ||
<source>.</source> | ||
</sources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<!-- code format --> | ||
<plugin> | ||
<groupId>com.diffplug.spotless</groupId> | ||
<artifactId>spotless-maven-plugin</artifactId> | ||
<version>2.40.0</version> | ||
|
||
<configuration> | ||
|
||
<java> | ||
<includes> | ||
<include>**/*.java</include> | ||
</includes> | ||
|
||
<googleJavaFormat> | ||
<version>1.22.0</version> | ||
<style>AOSP</style> | ||
<reflowLongStrings>true</reflowLongStrings> | ||
</googleJavaFormat> | ||
<endWithNewline /> | ||
<removeUnusedImports /> | ||
<indent> | ||
<spaces>true</spaces> | ||
<spacesPerTab>2</spacesPerTab> | ||
</indent> | ||
<trimTrailingWhitespace /> | ||
</java> | ||
|
||
</configuration> | ||
|
||
<executions> | ||
<execution> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.sinch.sdk</groupId> | ||
<artifactId>sinch-sdk-java</artifactId> | ||
<version>${sinch.sdk.java.version}</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package voice.callouts; | ||
|
||
import com.sinch.sdk.domains.voice.*; | ||
import com.sinch.sdk.domains.voice.models.DestinationNumber; | ||
import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersTTS; | ||
|
||
public class TextToSpeech { | ||
|
||
public String call(VoiceService voiceService, String phoneNumber) { | ||
|
||
var calloutsService = voiceService.callouts(); | ||
|
||
var destination = DestinationNumber.valueOf(phoneNumber); | ||
var message = | ||
"Hello, this is a call from Sinch. Congratulations! You made your first call."; | ||
|
||
var parameters = | ||
CalloutRequestParametersTTS.builder() | ||
.setDestination(destination) | ||
.setText(message) | ||
.build(); | ||
|
||
var callId = calloutsService.textToSpeech(parameters); | ||
return callId; | ||
} | ||
} |