Changeset 35240
- Timestamp:
- 2021-08-03T14:36:14+12:00 (22 months ago)
- Location:
- gs3-extensions/atea-nlp-tools/trunk/src/koreromaori-proxy
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/atea-nlp-tools/trunk/src/koreromaori-proxy
-
Property svn:ignore
set to
build
-
Property svn:ignore
set to
-
gs3-extensions/atea-nlp-tools/trunk/src/koreromaori-proxy/build.xml
r35239 r35240 4 4 <property name="build.home" value="${basedir}/build" /> 5 5 <property name="web.dir" value="${basedir}/src/main/webapp" /> 6 <available property="ext.web.exists" file="${basedir}/web" type="dir" />7 6 8 7 <condition property="tomcat.dir" value="${gs3.tomcat.installed.path}" else="${basedir}/../../../packages/tomcat"> … … 24 23 25 24 <!-- Targets --> 25 <target name="file-checks" description="Ensures that required external files exist."> 26 <fail message="config.properties was not found. Please run ${basedir}/setup.sh"> 27 <condition> 28 <not> 29 <available file="${basedir}/config.properties"></available> 30 </not> 31 </condition> 32 </fail> 33 </target> 34 26 35 <target name="usage" description="Print a help message"> 27 36 <echo message=" Execute 'ant -projecthelp' for a list of targets." /> 28 37 <echo message=" Execute 'ant -help' for Ant help." /> 29 <echo>30 To install the servlet for the Korero Maori31 </echo>32 38 </target> 33 39 … … 46 52 </classpath> 47 53 </javac> 48 49 <copy file="${basedir}/log4j2.xml" todir="${build.classes}" />50 51 <!-- Package our classes into a jar -->52 <!--<jar destfile="${build.home}/lib/gs3-koreromaori.jar">53 <fileset dir="${build.home}">54 <include name="org/atea/**" />55 </fileset>56 <manifest>57 <attribute name="Built-By" value="${user.name}" />58 </manifest>59 </jar>-->60 54 </target> 61 55 62 <target name="package" depends=" compile" description="Packages the Korero Maori interface into a war file">56 <target name="package" depends="file-checks,compile" description="Packages the Korero Maori interface into a war file."> 63 57 <echo message="Creating ${guild.home}/gs3-koreromaori.war" /> 58 59 <!-- <copy file="${basedir}/config.properties" todir="${build.classes}" /> 60 <echo message="Copied configuration file" /> --> 61 <copy file="${basedir}/log4j2.xml" todir="${build.classes}" /> 64 62 65 63 <war destfile="${build.home}/gs3-koreromaori.war" webxml="${web.dir}/WEB-INF/web.xml"> 66 64 <fileset dir="${web.dir}/webContent" includes="**" /> 65 <fileset file="${basedir}/config.properties" /> 67 66 68 67 <lib dir="lib/java"> -
gs3-extensions/atea-nlp-tools/trunk/src/koreromaori-proxy/log4j2.xml
r35239 r35240 2 2 <Configuration status="warn" name="KoreroMaoriInterface" packages=""> 3 3 <Appenders> 4 <File name="FileOutput" fileName="../webapps/gs3-koreromaori/ koreromaoriinterface.log" append="true">4 <File name="FileOutput" fileName="../webapps/gs3-koreromaori/log.log" append="true"> 5 5 <PatternLayout> 6 6 <Pattern>%d %p %c{1.} [%t] %m%n</Pattern> -
gs3-extensions/atea-nlp-tools/trunk/src/koreromaori-proxy/src/main/java/org/atea/nlptools/koreromaoriinterface/TranscriptionServlet.java
r35239 r35240 1 1 package org.atea.nlptools.koreromaoriinterface; 2 2 3 import java.io.FileInputStream; 3 4 import java.io.IOException; 4 5 import java.io.InputStream; … … 7 8 import java.util.ArrayList; 8 9 import java.util.List; 10 import java.util.Properties; 9 11 10 12 import javax.servlet.ServletException; … … 34 36 35 37 private final Gson jsonSerialiser; 36 private final ReoTuhituhiApiService transcriptionService; 38 39 private ReoTuhituhiApiService transcriptionService; 37 40 38 41 public TranscriptionServlet() 39 42 { 40 43 jsonSerialiser = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); 41 this.transcriptionService = new ReoTuhituhiApiService(jsonSerialiser); 44 } 45 46 @Override 47 public void init() 48 { 49 Properties prop = new Properties(); 50 51 try { 52 FileInputStream fis = new FileInputStream("../webapps/gs3-koreromaori/config.properties"); 53 prop.load(fis); 54 fis.close(); 55 } catch (IOException e) { 56 e.printStackTrace(); 57 } 58 59 String apiEndpoint = prop.getProperty("tuhituhi.api.endpoint"); 60 String apiKey = prop.getProperty("tuhituhi.api.key"); 61 62 this.transcriptionService = new ReoTuhituhiApiService(jsonSerialiser, apiEndpoint, apiKey); 42 63 } 43 64 -
gs3-extensions/atea-nlp-tools/trunk/src/koreromaori-proxy/src/main/java/org/atea/nlptools/koreromaoriinterface/services/ReoTuhituhiApiService.java
r35239 r35240 25 25 private final ExecutorService threadPool; 26 26 private final Gson jsonSerialiser; 27 private final String apiEndpoint; 28 private final String apiKey; 27 29 28 public ReoTuhituhiApiService(Gson jsonSerialiser )30 public ReoTuhituhiApiService(Gson jsonSerialiser, String apiEndpoint, String apiKey) 29 31 { 30 32 this.jsonSerialiser = jsonSerialiser; 33 this.apiEndpoint = apiEndpoint; 34 this.apiKey = apiKey; 31 35 32 36 threadPool = java.util.concurrent.Executors.newFixedThreadPool(3); … … 87 91 throws Exception 88 92 { 89 // TODO: Use servlet param for URL90 // TODO: Use servlet param for API key91 93 String jsonResponse = HttpRequestService 92 .post( "https://asr.koreromaori.io/transcribe_with_metadata")93 .authorization("Basic " )94 .post(apiEndpoint) 95 .authorization("Basic " + apiKey) 94 96 .send(audioStream) 95 97 .body();
Note:
See TracChangeset
for help on using the changeset viewer.