This file contains hidden or 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
{ | |
"name": "azure-gpt4o-audio", | |
"version": "1.0.0", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"start": "tsc && node index.js" | |
}, | |
"keywords": [], | |
"author": "", |
This file contains hidden or 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
import { OpenAIRealtimeWebSocket } from 'openai/beta/realtime/websocket'; | |
import { AzureOpenAI } from "openai"; | |
import Speaker from "speaker"; | |
import "dotenv/config"; | |
// configure the speaker instance -- this will pipe the audio to the speakers in realtime | |
const speaker = new Speaker({ | |
channels: 1, // mono channel | |
bitDepth: 16, // 16-bit | |
sampleRate: 24000, // 24Khz |
This file contains hidden or 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
@Test | |
void shouldPersistBattery() throws Exception { | |
Battery mockBattery = | |
new Battery("Gold Coast Mc", "9729", 50000); | |
mockMvc | |
.perform( | |
post("/batteries") | |
.content(objectMapper.writeValueAsString(mockBattery)) | |
.contentType(MediaType.APPLICATION_JSON) |
This file contains hidden or 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
@Test | |
void shouldReturnAllBatteries() throws Exception { | |
mockMvc | |
.perform(get("/batteries/")) | |
.andDo(print()) | |
.andExpect(status().isOk()) | |
.andExpect(jsonPath("$").isArray()) | |
.andExpect(jsonPath("$", Matchers.hasSize(H2Bootstrap.mockBatteries.size()))); | |
} |
This file contains hidden or 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
package np.com.roshanadhikary.testdemo; | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | |
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | |
@SpringBootTest | |
@AutoConfigureMockMvc | |
class ApplicationTests { | |
// .. |
This file contains hidden or 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
package np.com.roshanadhikary.testdemo; | |
@SpringBootTest | |
@AutoConfigureMockMvc | |
class ApplicationTests { | |
@Autowired | |
private MockMvc mockMvc; | |
@Autowired |
This file contains hidden or 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
spring.h2.console.enabled=true | |
spring.datasource.url=jdbc:h2:mem:testdb | |
spring.datasource.driverClassName=org.h2.Driver | |
spring.datasource.username=user | |
spring.datasource.password=password | |
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect |
This file contains hidden or 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
package np.com.roshanadhikary.testdemo.bootstrap; | |
/** | |
* Bootstrap the in-memory H2 database with some Battery resources when | |
* the application starts | |
*/ | |
@Configuration | |
public class H2Bootstrap { | |
private static final Logger logger = LoggerFactory.getLogger(H2Bootstrap.class); |
This file contains hidden or 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
package np.com.roshanadhikary.testdemo.repository; | |
import np.com.roshanadhikary.testdemo.entity.Battery; | |
import org.springframework.data.jpa.repository.JpaRepository; | |
public interface BatteryRepository extends JpaRepository<Battery, Integer> { | |
} |
This file contains hidden or 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
package np.com.roshanadhikary.testdemo.entity; | |
import lombok.Data; | |
import lombok.NoArgsConstructor; | |
import lombok.NonNull; | |
import lombok.RequiredArgsConstructor; | |
import javax.persistence.*; | |
/** |
NewerOlder